Module: Lithos
- Defined in:
- lib/lithos.rb,
lib/lithos/version.rb,
ext/lithos/lithos.cpp
Overview
lithos — a small embedded, ordered, crash-safe key-value store.
Lithos.open("data/db") do |db|
db["alpha"] = "1"
db.put("\x00bin\xff", "raw") # binary keys/values welcome
db["alpha"] # => "1"
db.scan(gte: "a", lt: "m") { |k, v| } # ordered range
end # auto-closed (flushes + fsyncs)
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.open(path, **opts) ⇒ Object
Open a store at ‘path` (a directory, created if missing).
Class Method Details
.open(path, **opts) ⇒ Object
Open a store at ‘path` (a directory, created if missing). Options:
sync: durably fsync each write before it returns (default true)
memtable_bytes: flush the in-memory table to an SSTable past this size
With a block: yields the store, closes it when the block returns (even on error), and returns the block’s value. Without a block: returns the store, and the caller must #close it.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lithos.rb', line 22 def self.open(path, **opts) db = DB.new(path, **opts) return db unless block_given? begin yield db ensure db.close end end |