instance method
namespace_key
Ruby on Rails 8.0.4
Since v5.2.8.1 Private — implementation detail, not part of the public APISignature
namespace_key(key, call_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 -
call_optionsopt = nil
Source
# File activesupport/lib/active_support/cache.rb, line 949
def namespace_key(key, call_options = nil)
namespace = if call_options&.key?(:namespace)
call_options[:namespace]
else
options[:namespace]
end
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 949
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Cache::Store