instance method
namespace_key
Ruby on Rails 7.0.10
Since v5.2.8.1 Private — implementation detail, not part of the public APISignature
namespace_key(key, options = nil)
Prefix the key with a namespace string:
namespace_key 'foo', namespace: 'cache'
# => 'cache:foo'
With a namespace block:
namespace_key 'foo', namespace: -> { 'cache' }
# => 'cache:foo'
Parameters
-
keyreq -
optionsopt = nil
Source
# File activesupport/lib/active_support/cache.rb, line 725
def namespace_key(key, options = nil)
options = merged_options(options)
namespace = options[:namespace]
if namespace.respond_to?(:call)
namespace = namespace.call
end
if key && key.encoding != Encoding::UTF_8
key = key.dup.force_encoding(Encoding::UTF_8)
end
if namespace
"#{namespace}:#{key}"
else
key
end
end
Defined in activesupport/lib/active_support/cache.rb line 725
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Cache::Store