instance method
normalize_key
Ruby on Rails 8.0.4
Since v5.2.8.1 PrivateSignature
normalize_key(key, options)
Translate a key into a file path.
Parameters
-
keyreq -
optionsreq
Source
# File activesupport/lib/active_support/cache/file_store.rb, line 162
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 162
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Cache::FileStore