Minimal SQLite key-value store for OCaml
0
fork

Configure Feed

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

sqlite: fix README — pure OCaml btree not C bindings, create→open_, get→find

+10 -9
+10 -9
README.md
··· 4 4 5 5 ## Overview 6 6 7 - A simple key-value store backed by SQLite with support for: 7 + A pure OCaml key-value store that reads and writes the SQLite file format, 8 + backed by a B-tree implementation. Supports: 8 9 - Namespaced tables for organizing data 9 10 - WAL mode for concurrent access 10 11 - Efficient batch operations ··· 20 21 21 22 ```ocaml 22 23 (* Open or create a database *) 23 - let db = Sqlite.create (Eio.Path.(fs / "data.db")) in 24 + Eio.Switch.run @@ fun sw -> 25 + let db = Sqlite.open_ ~sw (Eio.Path.(fs / "data.db")) in 24 26 25 27 (* Basic key-value operations *) 26 28 Sqlite.put db "key1" "value1"; 27 - let value = Sqlite.get db "key1" in (* Some "value1" *) 29 + let value = Sqlite.find db "key1" in (* Some "value1" *) 28 30 29 31 (* Namespaced tables *) 30 32 let blocks = Sqlite.Table.create db ~name:"blocks" in ··· 41 43 42 44 ### Database 43 45 44 - - `Sqlite.create path` - Open or create a SQLite database at path 45 - - `Sqlite.get db key` - Get value for key, or None 46 + - `Sqlite.open_ ~sw ?create path` - Open or create a SQLite database at path 47 + - `Sqlite.find db key` - Get value for key, or None 46 48 - `Sqlite.put db key value` - Store value at key 47 49 - `Sqlite.delete db key` - Remove key 48 50 - `Sqlite.mem db key` - Check if key exists ··· 58 60 59 61 ## Related Work 60 62 61 - - [sqlite3-ocaml](https://github.com/mmottl/sqlite3-ocaml) - Low-level SQLite3 bindings (used internally) 63 + - [sqlite3-ocaml](https://github.com/mmottl/sqlite3-ocaml) - Low-level SQLite3 C bindings 62 64 - [ezsqlite](https://opam.ocaml.org/packages/ezsqlite/) - Alternative SQLite bindings with extensions 63 65 - [irmin](https://github.com/mirage/irmin) - Git-like distributed database (different use case) 64 66 65 - ## Future: Pure OCaml Implementation 67 + ## Pure OCaml Implementation 66 68 67 - The current implementation uses C bindings via sqlite3-ocaml. A future pure OCaml 68 - implementation would enable: 69 + This implementation is written in pure OCaml using a B-tree backend. This enables: 69 70 - Unikernel deployment (MirageOS, Solo5) 70 71 - Browser targets via js_of_ocaml 71 72 - Full control over I/O with bytesrw streaming