Sha256: 9e9d28e06f7f70a20dbaf8b27f937d95b473ae3c35c4f2eb9a4e068264a176b7
Contents?: true
Size: 622 Bytes
Versions: 1
Compression:
Stored size: 622 Bytes
Contents
require 'sdbm' module Cubbyhole class SDBM extend Forwardable def_delegators :@sdbm, :clear def initialize(name) @name = name @sdbm = ::SDBM.new("cubbyhole.sdbm") end def [](key) if str = @sdbm[munge_key(key)] Marshal.load(str) end end def []=(key, val) @sdbm[munge_key(key)] = Marshal.dump(val) end def keys @sdbm.keys.grep(/^#{@name}:/).map do |key| key.sub(/^#{@name}:/, "") end end def delete(key) @sdbm.delete(munge_key(key)) end def munge_key(key) "#{@name}:#{key}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cubbyhole-0.2.1 | lib/cubbyhole/sdbm.rb |