Status
Phase 4. This crate now provides closure-based transactions with atomic batch writes, internal Send+Sync synchronization, and file lock exclusion on top of file-backed persistence and crash recovery. The API is still pre-1.0 and may change before 1.0.
Track progress and roadmap: https://github.com/jamesgober/emdb-rs
Installation
[]
= "0.5"
Quick Start
use Emdb;
let db = open_in_memory;
db.insert?;
assert_eq!;
# Ok::
Persistence
use ;
let path = temp_dir.join;
let reopened = open?;
assert_eq!;
# let _cleanup = remove_file;
# Ok::
Manual compaction:
use Emdb;
let path = temp_dir.join;
let db = open?;
db.insert?;
db.compact?;
db.flush?;
# let _cleanup = remove_file;
# Ok::
Transactions
Commit path:
use Emdb;
let db = open_in_memory;
db.transaction?;
assert_eq!;
assert_eq!;
# Ok::
Rollback path:
use ;
let db = open_in_memory;
let failed = db.;
assert!;
assert_eq!;
# Ok::
Crash Safety
Transactions are written as BatchBegin ... BatchEnd records.
If a crash occurs before BatchEnd, the entire batch is discarded during
replay. If a crash occurs after BatchEnd, the entire batch is applied.
Features
ttl(default): per-record expiration and default TTL support.nested: dotted-prefix group operations andFocushandles.- persistence (core): append-only file log, replay-on-open, flush policy, and compaction.
- transactions (core): closure-based atomic batches with read-your-writes and crash-safe replay.
Concurrency
Emdb is Send + Sync and cheap to clone. Internally it uses a
reader/writer lock for state and a mutex for serialized storage appends.
use Arc;
use thread;
use Emdb;
let db = new;
db.insert?;
let mut workers = Vecnew;
for i in 0_u32..4
for worker in workers
assert!;
# Ok::
TTL Example
#
#
# Ok::
Nested Example
#
#
# Ok::
Goals
- Embedded-first — runs in-process; no separate server, no network.
- High performance — zero-copy reads, allocation-free hot paths, cache-friendly layout.
- Safe — strict
clippyprofile, nounwrapin library code, allunsafedocumented. - Small footprint — minimal dependency graph, fast compile times.
- Portable — Linux, macOS, Windows (x86_64 and ARM64).
Non-Goals
- Client-server operation (use a dedicated DBMS for that).
- A full SQL dialect at this stage.
- Distributed replication at this stage.
Related Projects
emdb is the Rust implementation. Implementations in other languages (Go, C, and others) are planned and will live under their own repositories.
License
Licensed under the Apache License, Version 2.0.
Copyright © 2026 James Gober.