An embedded, single-file key-value store for OCaml, inspired by BoltDB and LMDB.
at main 1.2 kB view raw
1(** Bucket operations for key-value storage *) 2 3(** Bucket handle parameterized by transaction mode *) 4type 'mode t 5 6(** Get a value by key. 7 8 The returned value is a zero-copy slice into the database and is only valid during 9 the transaction lifetime. Copy with {!Types.bytes_of_value} if you need the value 10 to outlive the transaction. *) 11val get : 'mode t -> Types.key -> (Types.value option, Error.t) result 12 13(** Put a key-value pair (only in read-write mode). 14 15 The value will be copied into the database. *) 16val put : Types.rw t -> Types.key -> Types.value -> (unit, Error.t) result 17 18(** Put a key-value pair from bytes (convenience function) *) 19val put_bytes : Types.rw t -> Types.key -> bytes -> (unit, Error.t) result 20 21(** Delete a key (only in read-write mode) *) 22val delete : Types.rw t -> Types.key -> (unit, Error.t) result 23 24(** Create or open a nested bucket (only in read-write mode). 25 26 Bucket names are stored as keys. *) 27val create_bucket : Types.rw t -> Types.key -> (Types.rw t, Error.t) result 28 29(** Open a nested bucket *) 30val bucket : 'mode t -> Types.key -> ('mode t option, Error.t) result 31 32(** Create a cursor for iteration *) 33val cursor : 'mode t -> 'mode Cursor.t