High level bindings for LMDB.
The LMDB database is a fast in-file key-value store that supports ACID transactions.
These bindings attempt to expose a typesafe yet low-overhead API.
First, an environment must be opened using
let env = Env.(create Rw ~flags:Flags.no_subdir "mydb")
Now the data file
mydb and lock file
mydb-lock have been created in the current directory.
One environment may contain multiple named and one unnamed key-value stores. They are called databases in the LMDB documentation, but called maps in these OCaml bindings.
('key, 'value, [< `Read | `Write], [< `Dup | `Uni ])
Map.t is a key-value store mapping OCaml values of type
'key to values of type
'value. Multiple values per key are supported on request.
Map, we can open the unnamed map and add our first value:
let map = Map.open_existing Nodup ~key:Conv.string ~value:Conv.string env in
Map.add map "Bactrian camel" "Elegant and beautiful animal with two humps."
module Mdb : sig ... end
Raw bindings for LMDB.
This library uses
[< `Read | `Write ] phantom types to encode the read/write permissions of transactions and cursors. The following values are used to request read-only or read-write permissions on environments, transactions and cursors.
module Env : sig ... end
Collection of maps stored in a single memory-mapped file.
module Txn : sig ... end
Series of operations on an environment performed atomically.
module Conv : sig ... end
Converters to and from the internal representation of keys and values. A converter contains serialising and deserialising functions as well as the flags applied when the converter is used in a map.
module Map : sig ... end
module Cursor : sig ... end
Iterators over maps.
Raised when adding an already existing key to a
`Uni map or adding an an already existing value with
Map.Flags.no_dup_data to a key of a
Also raised when trying to
add ~flags:Flags.append(_dup) non-sorted data.
pp_error Format.std_formatter e prepares a human-readable description of the given error code
n raised via