expire item#as_json when updated

This commit is contained in:
Emi Matchu 2013-06-27 00:00:37 -07:00
parent 9e3cac82ec
commit bf697cef7b
2 changed files with 8 additions and 0 deletions

View file

@ -10,6 +10,13 @@ module FragmentExpiration
end end
end end
def expire_key_in_all_locales(key)
I18n.available_locales.each do |locale|
localized_key = localize_fragment_key(key, locale)
Rails.cache.delete(localized_key)
end
end
private private
def controller def controller

View file

@ -22,6 +22,7 @@ class ItemObserver < ActionController::Caching::Sweeper
expire_fragment_in_all_locales("items/#{item.id}#item_link_partial") expire_fragment_in_all_locales("items/#{item.id}#item_link_partial")
expire_fragment_in_all_locales("items/#{item.id} header") expire_fragment_in_all_locales("items/#{item.id} header")
expire_fragment_in_all_locales("items/#{item.id} info") expire_fragment_in_all_locales("items/#{item.id} info")
expire_key_in_all_locales("items/#{item.id}#as_json")
end end
def expire_newest_items def expire_newest_items