diff options
Diffstat (limited to 'activesupport/lib/active_support/cache.rb')
| -rw-r--r-- | activesupport/lib/active_support/cache.rb | 25 | 
1 files changed, 17 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index d0e53eaf05..5011014e96 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/core_ext/string/strip'  module ActiveSupport    # See ActiveSupport::Cache::Store for documentation. @@ -275,7 +276,7 @@ module ActiveSupport        def fetch(name, options = nil)          if block_given?            options = merged_options(options) -          key = namespaced_key(name, options) +          key = normalize_key(name, options)            instrument(:read, name, options) do |payload|              cached_entry = read_entry(key, options) unless options[:force] @@ -302,7 +303,7 @@ module ActiveSupport        # Options are passed to the underlying cache implementation.        def read(name, options = nil)          options = merged_options(options) -        key = namespaced_key(name, options) +        key = normalize_key(name, options)          instrument(:read, name, options) do |payload|            entry = read_entry(key, options)            if entry @@ -334,7 +335,7 @@ module ActiveSupport          instrument_multi(:read, names, options) do |payload|            results = {}            names.each do |name| -            key = namespaced_key(name, options) +            key = normalize_key(name, options)              entry = read_entry(key, options)              if entry                if entry.expired? @@ -386,7 +387,7 @@ module ActiveSupport          instrument(:write, name, options) do            entry = Entry.new(value, options) -          write_entry(namespaced_key(name, options), entry, options) +          write_entry(normalize_key(name, options), entry, options)          end        end @@ -397,7 +398,7 @@ module ActiveSupport          options = merged_options(options)          instrument(:delete, name) do -          delete_entry(namespaced_key(name, options), options) +          delete_entry(normalize_key(name, options), options)          end        end @@ -408,7 +409,7 @@ module ActiveSupport          options = merged_options(options)          instrument(:exist?, name) do -          entry = read_entry(namespaced_key(name, options), options) +          entry = read_entry(normalize_key(name, options), options)            (entry && !entry.expired?) || false          end        end @@ -529,7 +530,7 @@ module ActiveSupport          # Prefix a key with the namespace. Namespace and key will be delimited          # with a colon. -        def namespaced_key(key, options) +        def normalize_key(key, options)            key = expanded_key(key)            namespace = options[:namespace] if options            prefix = namespace.is_a?(Proc) ? namespace.call : namespace @@ -537,8 +538,16 @@ module ActiveSupport            key          end +        def namespaced_key(*args) +          ActiveSupport::Deprecation.warn(<<-MESSAGE.strip_heredoc) +            `namespaced_key` is deprecated and will be removed from Rails 5.1. +            Please use `normalize_key` which will return a fully resolved key. +          MESSAGE +          normalize_key(*args) +        end +          def instrument(operation, key, options = nil) -          log { "Cache #{operation}: #{namespaced_key(key, options)}#{options.blank? ? "" : " (#{options.inspect})"}" } +          log { "Cache #{operation}: #{normalize_key(key, options)}#{options.blank? ? "" : " (#{options.inspect})"}" }            payload = { :key => key }            payload.merge!(options) if options.is_a?(Hash)  | 
