Clojure wrappers for lmdb - the best no-nonsense, no-surprise, fast key-value store.
make-db
(use 'clj-lmdb.simple :reload)
nil
user> (def db (make-db "/tmp"))
#'user/db
You can specify the max memory map size as well:
(use 'clj-lmdb.core :reload)
nil
user> (def db (make-db "/tmp" <size_in_bytes>))
#'user/db
get!
and put!
user> (put! db "foo" "bar")
nil
user> (get! db "foo")
"bar"
user>
delete!
user> (delete! db "foo")
true
user> (get! db "foo")
nil
user>
read-txn
to create a read-only transaction
write-txn
to create a transaction that updates the db
This inserts a couple of entries:
(with-txn [txn (write-txn db)]
(put! db
txn
"foo"
"bar")
(put! db
txn
"foo1"
"bar1"))
This retrieves them
(with-txn [txn (read-txn db)]
(= (get! db
txn
"foo")
"bar") ; true
(= (get! db
txn
"foo1")
"bar1")) ; true
Inside a read-transaction you can use items
or items-from
to iterate over the entries or to iterate from a particular key onwards.
(with-txn [txn (read-txn db)]
(count
(doall
(map
(fn [[k v]]
...)
(items db txn)))))
(with-txn [txn (read-txn db)]
(count
(doall
(map
(fn [[k v]]
...)
(items-from db txn "foo")))))
For more examples, see the tests
Copyright © 2016 Shriphani Palakodety
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.