instance method normalize_key

Ruby on Rails 6.1.7.10

Since v5.2.8.1 Private

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

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

key req
options req
Source
# File activesupport/lib/active_support/cache/mem_cache_store.rb, line 187
        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, 213]}:md5:#{ActiveSupport::Digest.hexdigest(key)}" if key.size > 250
          end

          key
        end

Defined in activesupport/lib/active_support/cache/mem_cache_store.rb line 187 · 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