Sha256: d56b2b235b174725cd9acd84d4c60aecc61043c8174322626d765caffb33afd0

Contents?: true

Size: 550 Bytes

Versions: 1

Compression:

Stored size: 550 Bytes

Contents

# frozen_string_literal: true

module Kubo
  # Base caching class
  class Zip < BaseFile
    # Write the compressed value to file
    def save(key, value)
      path = get_file_path(key.to_s)
      file = File.new(path, "w+")
      file.puts(compress(value))
      file.close
    end

    # Decompress file
    def read(key)
      path = get_file_path(key.to_s)
      file = File.read(path)
      Zlib::Inflate.inflate(file)
    end

    private

    # Compress file to gz
    def compress(value)
      Zlib::Deflate.deflate(value)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kubo-1.0.1 lib/kubo/zip.rb