An embedded, single-file key-value store for OCaml, inspired by BoltDB and LMDB.
1(** Core types for Lithos *)
2
3(** Phantom type for read-only transactions *)
4type ro
5
6(** Phantom type for read-write transactions *)
7type rw
8
9type page_id = int64
10
11type metadata =
12 { version : int
13 ; page_size : int
14 ; root_bucket : page_id option
15 }
16
17type txn_state =
18 | Active
19 | Committed
20 | Rolled_back
21
22(** Key type - represented as bytes for efficient binary key handling *)
23type key = bytes
24
25(** Value type - opaque Bigarray slice for zero-copy access to mmap'd data.
26
27 Values are only valid during the lifetime of the transaction that created them.
28 If you need a value to outlive the transaction, copy it with {!bytes_of_value}. *)
29type value = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
30
31val key_of_string : string -> key
32val string_of_key : key -> string
33
34val value_of_string : string -> value
35val string_of_value : value -> string
36
37val value_of_bytes : bytes -> value
38val bytes_of_value : value -> bytes