Sha256: a4456831a8c5baa15b11eacc146bb16e46a613ee4125172cc09262821a647ae4
Contents?: true
Size: 633 Bytes
Versions: 5
Compression:
Stored size: 633 Bytes
Contents
require "pstore" require "fileutils" module Ykxutils class Pstorex def initialize(store_dir, dump_file = "pstore.dump") FileUtils.mkdir_p(store_dir) @store_db = PStore.new(Pathname.new(store_dir).join(dump_file)) end def fetch(key, default_value) value = default_value @store_db.transaction do value = @store_db.fetch(key, default_value) end value end def store(key, value) @store_db.transaction do @store_db[key] = value end end def delete(key) @store_db.transaction do @store_db.delete(key) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems