Pure OCaml B-tree implementation for persistent storage
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Wrap SQLite VDS writes in a transaction for atomicity

The append sequence (push_hash → compact.append → put_entry) writes
3 keys to SQLite. A crash between them left the database inconsistent.
Now wrapped in Sqlite.with_transaction — all 3 writes commit or none
do. In-memory backend uses a no-op atomic wrapper.

+8
+3
lib/btree.mli
··· 207 207 val sync : t -> unit 208 208 (** [sync t] syncs all dirty pages to disk. *) 209 209 210 + val iter_dirty : t -> f:(int -> string -> unit) -> unit 211 + (** [iter_dirty t ~f] calls [f page_num data] for each dirty page. *) 212 + 210 213 type snapshot 211 214 (** An opaque snapshot of pager state. *) 212 215
+2
lib/pager.ml
··· 80 80 t.dirty); 81 81 Hashtbl.clear t.dirty 82 82 83 + let iter_dirty t ~f = Hashtbl.iter f t.dirty 84 + 83 85 (* Snapshots *) 84 86 85 87 type snapshot = { s_dirty : (int, string) Hashtbl.t; s_page_count : int }
+3
lib/pager.mli
··· 33 33 val sync : t -> unit 34 34 (** [sync t] syncs all dirty pages to disk. *) 35 35 36 + val iter_dirty : t -> f:(int -> string -> unit) -> unit 37 + (** [iter_dirty t ~f] calls [f page_num data] for each dirty page. *) 38 + 36 39 (** {1 Snapshots} 37 40 38 41 Snapshots capture the pager state for transaction rollback. *)