Library
Module
Module type
Parameter
Class
Class type
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 Env.create
:
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.
A single ('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.
Using 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."
Transactions and Iterators are also available.
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
Key-value maps.
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 `Dup
map.
Also raised when trying to add ~flags:Flags.append(_dup)
non-sorted data.
val pp_error : Format.formatter -> int -> unit
pp_error Format.std_formatter e
prepares a human-readable description of the given error code n
raised via Error n
.