2006-04-02 08:17:05 +02:00
|
|
|
require_dependency 'cache_sweeping_helper'
|
|
|
|
|
2006-03-19 22:49:53 +01:00
|
|
|
class RevisionSweeper < ActionController::Caching::Sweeper
|
2006-04-02 08:17:05 +02:00
|
|
|
|
|
|
|
include CacheSweepingHelper
|
|
|
|
|
2006-03-19 22:49:53 +01:00
|
|
|
observe Revision, Page
|
|
|
|
|
|
|
|
def after_save(record)
|
|
|
|
if record.is_a?(Revision)
|
|
|
|
expire_caches(record.page)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def after_delete(record)
|
|
|
|
if record.is_a?(Page)
|
|
|
|
expire_caches(record)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def expire_caches(page)
|
2006-04-02 08:17:05 +02:00
|
|
|
expire_cached_summary_pages(page.web)
|
2007-09-28 05:57:52 +02:00
|
|
|
pages_to_expire = ([page.name] + WikiReference.pages_that_reference(page.web, page.name)).uniq
|
2006-04-02 08:17:05 +02:00
|
|
|
pages_to_expire.each { |page_name| expire_cached_page(page.web, page_name) }
|
2006-03-19 22:49:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|