Page
Library
Module
Module type
Parameter
Class
Class type
Source
LmdbSourceHigh 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.
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.
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.
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.
Raised when searching for non-existing key
Raised when memory map is full
Other errors are reported with Invalid_arg s or Error n.
pp_error Format.std_formatter e prepares a human-readable description of the given error code n raised via Error n.
(name, major, minor, patch)