Sha256: 29e9cbf74779fe5a276cdd17c4baa0516603c92e64c6b4885c254fe60adab601
Contents?: true
Size: 631 Bytes
Versions: 2
Compression:
Stored size: 631 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ykxutils-0.1.7 | lib/ykxutils/pstorex.rb |
ykxutils-0.1.6 | lib/ykxutils/pstorex.rb |