aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/cache_helper.rb
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2015-02-15 20:34:18 +0100
committerKasper Timm Hansen <kaspth@gmail.com>2015-02-20 20:07:50 +0100
commite56c63542780fe2fb804636a875f95cae08ab3f4 (patch)
tree770d129fff282d798e80779f6a44ff048fec1621 /actionview/lib/action_view/helpers/cache_helper.rb
parent66a30dc3225589d8aba6c10fee7bfa68da444e49 (diff)
downloadrails-e56c63542780fe2fb804636a875f95cae08ab3f4.tar.gz
rails-e56c63542780fe2fb804636a875f95cae08ab3f4.tar.bz2
rails-e56c63542780fe2fb804636a875f95cae08ab3f4.zip
Merge multi_fetch_fragments.
Makes caching a collection of template partials faster using `read_multi` on the Rails cache store. Some caching implementations have optimized `read_multi` so we don't have to check in the cache store for every template.
Diffstat (limited to 'actionview/lib/action_view/helpers/cache_helper.rb')
-rw-r--r--actionview/lib/action_view/helpers/cache_helper.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/actionview/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb
index 4db8930a26..56b1c5049c 100644
--- a/actionview/lib/action_view/helpers/cache_helper.rb
+++ b/actionview/lib/action_view/helpers/cache_helper.rb
@@ -161,6 +161,14 @@ module ActionView
end
end
+ # Given a key (as described in ActionController::Caching::Fragments.expire_fragment),
+ # returns a key suitable for use in reading, writing, or expiring a
+ # cached fragment. All keys are prefixed with <tt>views/</tt> and uses
+ # ActiveSupport::Cache.expand_cache_key for the expansion.
+ def fragment_cache_key(key)
+ ActiveSupport::Cache.expand_cache_key(key.is_a?(Hash) ? url_for(key).split("://").last : key, :views)
+ end
+
private
def fragment_name_with_digest(name) #:nodoc: