Class: Kubo::Zip
Overview
Base caching class
Instance Attribute Summary
Attributes inherited from BaseFile
Instance Method Summary collapse
-
#read(key) ⇒ Object
Decompress file.
-
#save(key, value) ⇒ Object
Write the compressed value to file.
Methods inherited from BaseFile
#delete, #delete_if_expired, #expired?, #file_empty?, #file_exists?, #flush, #get_file_path, #initialize, #parse_path, #parse_time
Constructor Details
This class inherits a constructor from Kubo::BaseFile
Instance Method Details
#read(key) ⇒ Object
Decompress file
15 16 17 18 19 |
# File 'lib/kubo/zip.rb', line 15 def read(key) path = get_file_path(key.to_s) file = File.read(path) Zlib::Inflate.inflate(file) end |
#save(key, value) ⇒ Object
Write the compressed value to file
7 8 9 10 11 12 |
# File 'lib/kubo/zip.rb', line 7 def save(key, value) path = get_file_path(key.to_s) file = File.new(path, "w+") file.puts(compress(value)) file.close end |