diff options
author | Peter Wagenet <peter.wagenet@gmail.com> | 2014-06-27 12:07:06 -0700 |
---|---|---|
committer | Peter Wagenet <peter.wagenet@gmail.com> | 2014-06-27 14:13:10 -0700 |
commit | acee114ba00f67e485355b0eb3d7cb26bf283d6f (patch) | |
tree | 2052b96aaa4d0eab0c2eda0f27011cba736caa27 /activesupport | |
parent | 5add8b8d6d27afac9fe46bcee09cd341fb124294 (diff) | |
download | rails-acee114ba00f67e485355b0eb3d7cb26bf283d6f.tar.gz rails-acee114ba00f67e485355b0eb3d7cb26bf283d6f.tar.bz2 rails-acee114ba00f67e485355b0eb3d7cb26bf283d6f.zip |
Always instrument ActiveSupport::Cache
The current approach is broken because it uses a thread local value
which means on multi-threaded environments it has to be turned on
per thread. Secondly, ActiveSupport::Notifications does not
instrument items when there are not subscribers so this flag is
unnecessary.
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/cache.rb | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index a627fa8651..8c538d335a 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -8,6 +8,7 @@ require 'active_support/core_ext/numeric/bytes' require 'active_support/core_ext/numeric/time' require 'active_support/core_ext/object/to_param' require 'active_support/core_ext/string/inflections' +require 'active_support/deprecation' module ActiveSupport # See ActiveSupport::Cache::Store for documentation. @@ -178,14 +179,16 @@ module ActiveSupport @silence = previous_silence end - # Set to +true+ if cache stores should be instrumented. - # Default is +false+. + # :deprecated: def self.instrument=(boolean) - Thread.current[:instrument_cache_store] = boolean + ActiveSupport::Deprecation.warn "ActiveSupport::Cache.instrument is deprecated and will be removed in Rails 5. Instrumentation is now always on so you can safely stop using it." + true end + # :deprecated: def self.instrument - Thread.current[:instrument_cache_store] || false + ActiveSupport::Deprecation.warn "ActiveSupport::Cache.instrument is deprecated and will be removed in Rails 5. Instrumentation is now always on so you can safely stop using it." + true end # Fetches data from the cache, using the given key. If there is data in @@ -539,13 +542,9 @@ module ActiveSupport def instrument(operation, key, options = nil) log(operation, key, options) - if self.class.instrument - payload = { :key => key } - payload.merge!(options) if options.is_a?(Hash) - ActiveSupport::Notifications.instrument("cache_#{operation}.active_support", payload){ yield(payload) } - else - yield(nil) - end + payload = { :key => key } + payload.merge!(options) if options.is_a?(Hash) + ActiveSupport::Notifications.instrument("cache_#{operation}.active_support", payload){ yield(payload) } end def log(operation, key, options = nil) |