aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorStan Lo <a22301613@yahoo.com.tw>2015-12-31 09:41:48 +0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2016-02-23 21:06:40 -0300
commit1de6f7938dbc58a618a89397aad5f217a6221d17 (patch)
treec8a3cefd9748e778422e2509afd753516c8fd917 /actionpack
parent3e824d3f5b32bae70832fe0c1c329ce062f79ff9 (diff)
downloadrails-1de6f7938dbc58a618a89397aad5f217a6221d17.tar.gz
rails-1de6f7938dbc58a618a89397aad5f217a6221d17.tar.bz2
rails-1de6f7938dbc58a618a89397aad5f217a6221d17.zip
Make caching configuration more flexible
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/caching.rb12
-rw-r--r--actionpack/lib/action_dispatch/caching/fragments.rb9
2 files changed, 14 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb
index e832f4adf4..999c2636da 100644
--- a/actionpack/lib/action_controller/caching.rb
+++ b/actionpack/lib/action_controller/caching.rb
@@ -29,5 +29,17 @@ module ActionController
included do
include ActionDispatch::Caching
end
+
+ def instrument_payload(key)
+ {
+ controller: controller_name,
+ action: action_name,
+ key: key
+ }
+ end
+
+ def instrument_name
+ "action_controller"
+ end
end
end
diff --git a/actionpack/lib/action_dispatch/caching/fragments.rb b/actionpack/lib/action_dispatch/caching/fragments.rb
index c410aaf03a..dcc490776e 100644
--- a/actionpack/lib/action_dispatch/caching/fragments.rb
+++ b/actionpack/lib/action_dispatch/caching/fragments.rb
@@ -135,13 +135,8 @@ module ActionDispatch
end
def instrument_fragment_cache(name, key) # :nodoc:
- payload = {
- controller: controller_name,
- action: action_name,
- key: key
- }
-
- ActiveSupport::Notifications.instrument("#{name}.action_controller", payload) { yield }
+ payload = instrument_payload(key)
+ ActiveSupport::Notifications.instrument("#{name}.#{instrument_name}", payload) { yield }
end
end
end