activesupport/lib/active_support/cache/file_store.rb
# Translate a key into a file path.
Translate a key into a file path.
Translate a key into a file path .
def key_file_path(key)
          if key.size > FILEPATH_MAX_SIZE
            key = Digest::MD5.hexdigest(key)
          end
          fname = URI.encode_www_form_component(key)
          hash = Zlib.adler32(fname)
          hash, dir_1 = hash.divmod(0x1000)
          dir_2 = hash.modulo(0x1000)
          fname_paths = []
          begin
            fname_paths << fname[0, FILENAME_MAX_SIZE]
            fname = fname[FILENAME_MAX_SIZE..-1]
          end until fname.blank?
          File.join(cache_path, DIR_FORMATTER % dir_1, DIR_FORMATTER % dir_2, *fname_paths)
        end
def key_file_path ( key ) if key . size > FILEPATH_MAX_SIZE key = Digest :: MD5 . hexdigest ( key ) end fname = URI . encode_www_form_component ( key ) hash = Zlib . adler32 ( fname ) hash , dir_1 = hash . divmod ( 0x1000 ) dir_2 = hash . modulo ( 0x1000 ) fname_paths = [ ] begin fname_paths << fname [ 0 , FILENAME_MAX_SIZE ] fname = fname [ FILENAME_MAX_SIZE .. - 1 ] end until fname . blank? File . join ( cache_path , DIR_FORMATTER % dir_1 , DIR_FORMATTER % dir_2 , * fname_paths ) end
Translate a key into a file path.
Translate a key into a file path .
# Make sure file name doesn't exceed file system limits.
key
<not_specific>