metropolis.git  about / heads / tags
key-value store for Rack
blob d205a76da6be41f3f70325172e5681159bf6592e 390 bytes (raw)
$ git show HEAD:lib/metropolis/tc/hdb/ex.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
 
module Metropolis::TC::HDB::EX
  def self.extended(obj)
   obj.instance_eval do
      @wr_flags |= @rd_flags
      @rd_flags = nil
      @dbv.each { |(hdb, path)|
        hdb.open(path, @wr_flags) or ex!(:open, hdb)
      }
      @ex_dbv = @dbv.map { |(hdb,_)| hdb }
    end
  end

  def reader(key)
    yield @ex_dbv[multi_hash(key) % @nr_slots]
  end

  alias_method :writer, :reader
end

git clone https://yhbt.net/metropolis.git