A slight improvement in the efficiency of the Cache Sweeper
Suggested by Andrew Stacey
This commit is contained in:
parent
d30bd11ff7
commit
b6c0ffa0d5
|
@ -19,6 +19,14 @@ class RevisionSweeper < ActionController::Caching::Sweeper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def after_create(record)
|
||||||
|
if record.is_a?(Page)
|
||||||
|
WikiReference.pages_that_reference(record.web, record.name).each do |page_name|
|
||||||
|
expire_cached_page(record.web, page_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def after_delete(record)
|
def after_delete(record)
|
||||||
if record.is_a?(Page)
|
if record.is_a?(Page)
|
||||||
expire_caches(record)
|
expire_caches(record)
|
||||||
|
@ -33,7 +41,7 @@ class RevisionSweeper < ActionController::Caching::Sweeper
|
||||||
|
|
||||||
def expire_caches(page)
|
def expire_caches(page)
|
||||||
expire_cached_summary_pages(page.web)
|
expire_cached_summary_pages(page.web)
|
||||||
pages_to_expire = ([page.name] + WikiReference.pages_that_reference(page.web, page.name) +
|
pages_to_expire = ([page.name] +
|
||||||
WikiReference.pages_redirected_to(page.web, page.name) +
|
WikiReference.pages_redirected_to(page.web, page.name) +
|
||||||
WikiReference.pages_that_include(page.web, page.name)).uniq
|
WikiReference.pages_that_include(page.web, page.name)).uniq
|
||||||
pages_to_expire.each { |page_name| expire_cached_page(page.web, page_name) }
|
pages_to_expire.each { |page_name| expire_cached_page(page.web, page_name) }
|
||||||
|
|
Loading…
Reference in a new issue