Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
22 lines (14 sloc) 511 Bytes
# library providing a sorted disk-based key-value store with fast reads and writes
require 'leveldb' # gem install leveldb-ruby
db = "/tmp/db"
db.put "b", "bar"
db.put "a", "foo"
db.put "c", "baz"
puts db.get "a" # => foo
db.each do |k,v|
p [k,v] # => ["a", "foo"], ["b", "bar"], ["c", "baz"]
db.to_a # => [["a", "foo"], ["b", "bar"], ["c", "baz"]]
db.delete "c"