metropolis.git  about / heads / tags
key-value store for Rack
blob 72fa968b417bf51c430defb634a52e399072cc42 390 bytes (raw)
$ git show HEAD:lib/metropolis/tc/hdb/ro.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
19
 
# -*- encoding: binary -*-

module Metropolis::TC::HDB::RO
  include Metropolis::Common::RO

  def self.extended(obj)
   obj.instance_eval do
      @wr_flags = nil
      @dbv.each { |(hdb, path)|
        hdb.open(path, @rd_flags) or ex!(:open, hdb)
      }
      @ro_dbv = @dbv.map { |(hdb,_)| hdb }
    end
  end

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

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