class method
self.expand_cache_key
Ruby on Rails 8.0.4
Since v2.2.3Signature
self.expand_cache_key(key, namespace = nil)
Expands out the key argument into a key that can be used for the cache store. Optionally accepts a namespace, and all keys will be scoped within that namespace.
If the key argument provided is an array, or responds to to_a, then each of elements in the array will be turned into parameters/keys and concatenated into a single key. For example:
ActiveSupport::Cache.expand_cache_key([:foo, :bar]) # => "foo/bar" ActiveSupport::Cache.expand_cache_key([:foo, :bar], "namespace") # => "namespace/foo/bar"
The key argument can also respond to cache_key or to_param.
Parameters
-
keyreq -
namespaceopt = nil
Source
# File activesupport/lib/active_support/cache.rb, line 112
def expand_cache_key(key, namespace = nil)
expanded_cache_key = namespace ? +"#{namespace}/" : +""
if prefix = ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]
expanded_cache_key << "#{prefix}/"
end
expanded_cache_key << retrieve_cache_key(key)
expanded_cache_key
end
Defined in activesupport/lib/active_support/cache.rb line 112
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Cache