instance method
normalize_key
Ruby on Rails 7.0.10
Since v5.2.8.1 PrivateSignature
normalize_key(key, options)
Memcache keys are binaries. So we need to force their encoding to binary before applying the regular expression to ensure we are escaping all characters properly.
Parameters
-
keyreq -
optionsreq
Source
# File activesupport/lib/active_support/cache/mem_cache_store.rb, line 297
def normalize_key(key, options)
key = super
if key
key = key.dup.force_encoding(Encoding::ASCII_8BIT)
key = key.gsub(ESCAPE_KEY_CHARS) { |match| "%#{match.getbyte(0).to_s(16).upcase}" }
key = "#{key[0, 212]}:hash:#{ActiveSupport::Digest.hexdigest(key)}" if key.size > 250
end
key
end
Defined in activesupport/lib/active_support/cache/mem_cache_store.rb line 297
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Cache::MemCacheStore