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)

Translate a key into a file path.

Parameters

key req
options req
Source
# File activesupport/lib/active_support/cache/file_store.rb, line 121
        def normalize_key(key, options)
          key = super
          fname = URI.encode_www_form_component(key)

          if fname.size > FILEPATH_MAX_SIZE
            fname = ActiveSupport::Digest.hexdigest(key)
          end

          hash = Zlib.adler32(fname)
          hash, dir_1 = hash.divmod(0x1000)
          dir_2 = hash.modulo(0x1000)

          # Make sure file name doesn't exceed file system limits.
          if fname.length < FILENAME_MAX_SIZE
            fname_paths = fname
          else
            fname_paths = []
            begin
              fname_paths << fname[0, FILENAME_MAX_SIZE]
              fname = fname[FILENAME_MAX_SIZE..-1]
            end until fname.blank?
          end

          File.join(cache_path, DIR_FORMATTER % dir_1, DIR_FORMATTER % dir_2, fname_paths)
        end

Defined in activesupport/lib/active_support/cache/file_store.rb line 121 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::Cache::FileStore

Type at least 2 characters to search.

↑↓ navigate · open · esc close