Also Expire Caches
Removing orphaned pages, or deleting a Web should also expire all associated caches.
This commit is contained in:
parent
397859ba8a
commit
1b8bf36702
1 changed files with 14 additions and 4 deletions
|
@ -4,13 +4,15 @@ class WebSweeper < ActionController::Caching::Sweeper
|
||||||
|
|
||||||
include CacheSweepingHelper
|
include CacheSweepingHelper
|
||||||
|
|
||||||
observe Web
|
observe Web, Page
|
||||||
|
|
||||||
def after_save(record)
|
def after_save(record)
|
||||||
|
if record.is_a?(Web)
|
||||||
web = record
|
web = record
|
||||||
web.pages.each { |page| expire_cached_page(web, page.name) }
|
web.pages.each { |page| expire_cached_page(web, page.name) }
|
||||||
expire_cached_summary_pages(web)
|
expire_cached_summary_pages(web)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def after_remove_orphaned_pages(web)
|
def after_remove_orphaned_pages(web)
|
||||||
expire_cached_summary_pages(web)
|
expire_cached_summary_pages(web)
|
||||||
|
@ -20,4 +22,12 @@ class WebSweeper < ActionController::Caching::Sweeper
|
||||||
expire_cached_summary_pages(web)
|
expire_cached_summary_pages(web)
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue