method
normalize_key
v7.0.0 -
Show latest stable
- Class:
ActiveSupport::Cache::FileStore
normalize_key(key, options)private
Translate a key into a file path.
# File activesupport/lib/active_support/cache/file_store.rb, line 127
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 Related methods
- Instance methods
- cleanup
- clear
- decrement
- delete_matched
- increment
- Class methods
- new
- supports_cache_versioning?
- Private methods
-
delete_empty_directories -
delete_entry -
ensure_cache_path -
file_path_key -
lock_file -
modify_value -
normalize_key -
read_entry -
read_serialized_entry -
search_dir -
write_entry -
write_serialized_entry