DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
dbm.h File Reference

Log-structured hash key-value store on the WAL (DETWS_ENABLE_DBM, requires DETWS_ENABLE_WAL). More...

#include "ServerConfig.h"

Go to the source code of this file.

Detailed Description

Log-structured hash key-value store on the WAL (DETWS_ENABLE_DBM, requires DETWS_ENABLE_WAL).

A Bitcask-style key-value store: the value data lives append-only in the write-ahead log (wal_store.h) and an in-RAM open-addressed hash index maps each live key to where its latest value sits in the log. This is the design the measured SD envelope wants (docs/FEATURE_PERFORMANCE.md): every write is one of the WAL's fast sequential appends, never a slow durable random write.

  • put / delete append one record to the WAL and update the index. Writes are batched (unsynced); call ::detws_dbm_sync to checkpoint the WAL and make them durable.
  • get looks up the index and re-reads the value straight from the log (no per-key RAM copy).
  • open rebuilds the index by scanning the WAL, replaying puts and deletes in order, so the live key set is exactly what survived the last mount of the underlying store.

The index is a fixed BSS array of DETWS_DBM_SLOTS slots (no heap); keys are bounded by DETWS_DBM_KEY_MAX and values by DETWS_DBM_VAL_MAX. Everything fails closed at those bounds. Like the other services, drive it from one context (a worker / loop), not concurrently.

On-media record payload (inside a WAL record): [op u8][key_len u16][val_len u32][key][value] (LE), op 0 = put, op 1 = delete (a tombstone, val_len 0).

Definition in file dbm.h.