class ActiveSupport::Cache::Store

def namespace_key(key, options = nil)

# => 'cache:foo'
namespace_key 'foo', namespace: -> { 'cache' }

With a namespace block:

# => 'cache:foo'
namespace_key 'foo', namespace: 'cache'

Prefix the key with a namespace string:
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