Expand description
redb-backed kv backend (M4.D — DS-14-storage Audit 4, ACID transactions).
RedbBackend wraps a redb::Database as a StorageBackend. Each
write() / delete() opens its own write transaction and commits — ACID
guarantees per call. read() / list() use read transactions (concurrent
with any write). flush() is a no-op (writes are durable on commit).
Space reclamation is managed internally by redb; flush() is a no-op
since each write() commits its own transaction.
All keys live in a single "graphrefly" table (D162 — tiers already
namespace via key prefixes; a single table matches the flat-kv model of
[MemoryBackend] / [FileBackend]).
§Thread safety
redb::Database is Send + Sync. begin_write() serializes concurrent
writers by design (MVCC — one writer at a time, concurrent readers). No
additional synchronization needed on RedbBackend. This structurally
closes the F3 deferred concern (concurrent flush race on append-log) —
see porting-deferred.md.
§Crash safety
redb is crash-safe by default — committed transactions survive process
crashes. Unlike [FileBackend]’s per-file atomic-rename, redb provides
cross-key atomicity within a single transaction. The per-write-call
transaction granularity (D163) means each StorageBackend::write() is
individually atomic; cross-key atomicity (e.g., flushing multiple
append-log buckets) would require holding one transaction across multiple
calls, which isn’t supported by the current StorageBackend trait.
Cross-key atomicity at the tier level is a M4.E concern
(Graph::attach_storage batched flush).
Cargo feature: gated behind redb-store (default-on).
Structs§
- Redb
Backend - redb-backed
StorageBackend.
Functions§
- redb_
append_ log - Append-log tier over a redb backend at
path. - redb_
append_ log_ default - Append-log tier over a redb backend with default options (
JsonCodec). - redb_
backend - Open or create a redb database at
path, returning anArc<RedbBackend>. - redb_kv
- KV tier over a redb backend at
path. - redb_
kv_ default - KV tier over a redb backend with default options (
JsonCodec). - redb_
snapshot - Snapshot tier over a redb backend at
path. - redb_
snapshot_ default - Snapshot tier over a redb backend with default options (
JsonCodec).