Module Lmdb.Map
Key-value maps.
type ('key, 'value, -'dup) tconstraint 'perm = [< `Read | `Write ] constraint 'dup = [< `Dup | `Uni ]A handle for a map from keys of type
'keyto values of type'value. The map may support only a single value per key ([ `Dup ]) or multiple values per key ([ `Dup | `Uni ]).
val create : [< `Dup | `Uni ] as 'dup card -> key:'key Conv.t -> value:'value Conv.t -> ?txn:[> `Read | `Write ] Txn.t -> ?name:string -> Env.t -> ('key, 'value, 'dup) tcreate dup ~key ~value envopen (and possibly create) a map in the environmentenv.dupmay beDuporNodup, specifying whether the map supports multiple values per key.Only a single transaction may call this function at a time. This transaction needs to finish before any other transaction may call this function.
- parameter name
if omitted the unnamed map will be opened. Otherwise make sure that
Env.createwas called with a large enough~max_maps.
- parameter key
Converter for keys
- parameter value
Converter for values
- raises Invalid_argument
if an existing map doesn't support duplicates, but duplicates where requested.
val open_existing : [< `Dup | `Uni ] as 'dup card -> key:'key Conv.t -> value:'value Conv.t -> ?txn:[> `Read ] Txn.t -> ?name:string -> Env.t -> ('key, 'value, 'dup) topen_existing envis likecreate, but only opens already existing maps.- raises Not_found
if the map doesn't exist.
val get : ('key, 'value, _) t -> ?txn:[> `Read ] Txn.t -> 'key -> 'valueget map keyreturns the first value associated tokey.- raises Not_found
if the key is not in the map.
module Flags = Lmdb__.Lmdb_bindings.PutFlagsval add : ('key, 'value, _) t -> ?txn:[> `Write ] Txn.t -> ?flags:Flags.t -> 'key -> 'value -> unitadd map key valueaddsvaluetokey.For a map not supporting duplicates an existing value is overwritten. For a map supporting duplicates the value is added to the key. This is the same as
overwritefor duplicate maps, butoverwrite ~flags:Flags.no_overwritefor non-duplicate maps.- parameter flags
- raises Exists
on maps not supporting duplicates if the key already exists.
- raises Exists
if key is already bound to
valueandMap.Flags.no_dup_datawas passed.
val set : ('key, 'value, _) t -> ?txn:[> `Write ] Txn.t -> ?flags:Flags.t -> 'key -> 'value -> unitset map key valuesets binding ofkeytovalue.Values of an already existing key are silently overwritten.
- parameter flags
val remove : ('key, 'value, _) t -> ?txn:[> `Write ] Txn.t -> ?value:'value -> 'key -> unitremove map keyremoveskeyfrommap.- parameter value
Only the specified value is removed. If not provided, all the values of
keyandkeyitself are removed.
- raises Not_found
if the key is not in the map.
Misc
val stat : ?txn:[> `Read ] Txn.t -> ('key, 'value, _) t -> Mdb.statval drop : ?txn:[> `Write ] Txn.t -> ?delete:bool -> ('key, 'value, _) t -> unitdrop ?delete mapEmptiesmap.- parameter delete
If
truemapis also deleted from the environment and the handlemapinvalidated.
val compare_key : ('key, 'value, _) t -> ?txn:[> `Read ] Txn.t -> 'key -> 'key -> intcompare_key map ?txn a bComparesaandbas if they were keys inmap.