impress/app/models/fragment_expiration.rb
Matchu 4144b4dc74 only send cache deletions for usable locales
Right now we're spending too much time expiring cache keys when
getting contributions. The longer-term fix is to move it to a
background task, but it's good to restrict deletions only to usable
locales rather than all the ones that Rails theoretically supports.
2013-12-08 23:44:25 -06:00

25 lines
582 B
Ruby

module FragmentExpiration
include FragmentLocalization
delegate :expire_fragment, :to => :controller
def expire_fragment_in_all_locales(key)
I18n.usable_locales.each do |locale|
localized_key = localize_fragment_key(key, locale)
expire_fragment(localized_key)
end
end
def expire_key_in_all_locales(key)
I18n.usable_locales.each do |locale|
localized_key = localize_fragment_key(key, locale)
Rails.cache.delete(localized_key)
end
end
private
def controller
@controller ||= ActionController::Base.new
end
end