|
ZephyrDB
Embedded database for Zephyr RTOS: KV, time-series, and document models
|
Embedded multi-model database for Zephyr RTOS, designed for memory-constrained systems.
Key-value — namespaced records on NVS or ZMS, with byte and string APIs. A defaults table seeds product parameters at init and merges in newly added keys after a firmware update without disturbing values the device changed. Iteration covers every stored key, including those written before the current boot, and a namespace can be reset to its defaults for factory reset.
Time-series — append-only streams on LittleFS or FCB, buffered in RAM and flushed in the background. Cursors walk a time window in either direction, aggregates compute MIN/MAX/AVG/SUM/COUNT, and a consumed watermark records how far a forwarder has processed so a restart resumes rather than replays. Streams can be bounded, discarding the oldest samples to keep a recent window, and can store compact records that hold about 1.75x the samples per byte. Several streams can be open at once.
Documents — typed fields (integer, double, string, bool, bytes) with equality-filter queries, stored on a filesystem. Saves are atomic and integrity-checked end to end, so an interrupted write leaves the previous document intact rather than a truncated one.
Across all models — bounded, statically sized allocation on the core and time-series paths; corruption detection with recovery; optional mutation events, with a zbus adapter; optional FlatBuffers export for transport; and a zdb shell command tree.
For a complete standalone application example, see zephyrdb-example.
Planned and declined enhancements are tracked as GitHub issues.
ZephyrDB can report what it is doing, in four categories:
| Category | Payload | Events |
|---|---|---|
| Key-value | zdb_kv_event_t | set, delete, index-full |
| Time-series | zdb_ts_event_t | append, flush, recover, rollover, watermark |
| Document | zdb_doc_event_t | create, save, delete |
| Instance | zdb_core_event_t | init, deinit, health change |
Events carry the operation's real status, so failures are reported as well as successes. They are worth wiring up for the things that are otherwise invisible: a bounded stream discarding its oldest samples, an instance degrading after corruption, or a key that stored fine but no longer fits the iteration index.
See docs/api.md and the sample:
Use dedicated flash partitions when isolating ZephyrDB from app settings storage.
ZephyrDB integrates through:
See [LICENSE](LICENSE).