Also Expire Caches

Removing orphaned pages, or deleting a Web should also expire all associated
caches.
This commit is contained in:
Jacques Distler 2008-12-29 10:17:35 -06:00
parent 397859ba8a
commit 1b8bf36702

View file

@ -4,13 +4,15 @@ class WebSweeper < ActionController::Caching::Sweeper
include CacheSweepingHelper
observe Web
observe Web, Page
def after_save(record)
if record.is_a?(Web)
web = record
web.pages.each { |page| expire_cached_page(web, page.name) }
expire_cached_summary_pages(web)
end
end
def after_remove_orphaned_pages(web)
expire_cached_summary_pages(web)
@ -20,4 +22,12 @@ class WebSweeper < ActionController::Caching::Sweeper
expire_cached_summary_pages(web)
end
def after_destroy(record)
if record.is_a?(Web)
expire_cached_summary_pages(record)
else
expire_cached_page(record.web, record.name)
end
end
end