instance method escape_key

Ruby on Rails 4.1.16

Since v3.0.20 Last seen in v4.2.9 Private

Available in: v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9

Signature

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

key req
Source
# File activesupport/lib/active_support/cache/mem_cache_store.rb, line 158
        def escape_key(key)
          key = key.to_s.dup
          key = key.force_encoding(Encoding::ASCII_8BIT)
          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 158 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::Cache::MemCacheStore

Type at least 2 characters to search.

↑↓ navigate · open · esc close