Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Invalidate cached urls for all frontend locales

  • Loading branch information...
commit a0069f4c1d53575e384a39e96ac4e1784df60fc5 1 parent 0e34bd0
@vita vita authored
Showing with 10 additions and 8 deletions.
  1. +10 −8 pages/app/models/refinery/page.rb
View
18 pages/app/models/refinery/page.rb
@@ -294,16 +294,16 @@ def nested_path
Rails.cache.fetch(path_cache_key) { ['', nested_url].join('/') }
end
- def path_cache_key
- [cache_key, 'nested_path'].join('#')
+ def path_cache_key(locale=::I18n.locale)
+ [cache_key(locale), 'nested_path'].join('#')
end
- def url_cache_key
- [cache_key, 'nested_url'].join('#')
+ def url_cache_key(locale=::I18n.locale)
+ [cache_key(locale), 'nested_url'].join('#')
end
- def cache_key
- [Refinery::Core.base_cache_key, 'page', ::I18n.locale, id].compact.join('/')
+ def cache_key(locale)
+ [Refinery::Core.base_cache_key, 'page', locale, id].compact.join('/')
end
# Returns true if this page is "published"
@@ -415,8 +415,10 @@ def invalidate_cached_urls
return true unless Refinery::Pages.marketable_urls
[self, children].flatten.each do |page|
- Rails.cache.delete(page.url_cache_key)
- Rails.cache.delete(page.path_cache_key)
+ ::Refinery::I18n.frontend_locales.each do |locale|
+ Rails.cache.delete(page.url_cache_key(locale))
+ Rails.cache.delete(page.path_cache_key(locale))
+ end
end
end
alias_method :invalidate_child_cached_url, :invalidate_cached_urls
Please sign in to comment.
Something went wrong with that request. Please try again.