instance method
escape_key
Ruby on Rails 3.1.12
Since v3.0.20 Last seen in v4.2.9 PrivateSignature
escape_key(key)
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
Source
# File activesupport/lib/active_support/cache/mem_cache_store.rb, line 166
def escape_key(key)
key = key.to_s.dup
key = key.force_encoding("BINARY") if key.encoding_aware?
key = key.gsub(ESCAPE_KEY_CHARS){ |match| "%#{match.getbyte(0).to_s(16).upcase}" }
key = "#{key[0, 213]}:md5:#{Digest::MD5.hexdigest(key)}" if key.size > 250
key
end
Defined in activesupport/lib/active_support/cache/mem_cache_store.rb line 166
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Cache::MemCacheStore