Cache file_list Action
Also, slightly smarter cache expiry, upon uploading/deleting a file.
This commit is contained in:
parent
5c20871ec4
commit
b9f5c32755
5 changed files with 17 additions and 5 deletions
|
@ -4,13 +4,18 @@ class WebSweeper < ActionController::Caching::Sweeper
|
|||
|
||||
include CacheSweepingHelper
|
||||
|
||||
observe Web, Page
|
||||
observe Web, Page, WikiFile
|
||||
|
||||
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)
|
||||
elsif record.is_a?(WikiFile)
|
||||
record.web.pages_that_link_to(record.file_name).each do |page|
|
||||
expire_cached_page(record.web, page)
|
||||
end
|
||||
expire_cached_summary_pages(record.web)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,9 +30,11 @@ class WebSweeper < ActionController::Caching::Sweeper
|
|||
def after_destroy(record)
|
||||
if record.is_a?(Web)
|
||||
expire_cached_summary_pages(record)
|
||||
else
|
||||
elsif record.is_a?(Page)
|
||||
expire_cached_page(record.web, record.name)
|
||||
expire_cached_summary_pages(record.web)
|
||||
else
|
||||
expire_cached_summary_pages(record.web)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue