Add a local persistent key-value store to a Rust CLI tool or desktop app without running a separate database server.
Store typed key-value data that survives a program crash, with ACID transactions ensuring nothing is half-written.
Handle multiple concurrent readers without blocking writes in a Rust application that needs high read throughput.
Replace SQLite in a Rust app when you only need key-value storage and want compile-time type checking on table keys and values.
Add as a Cargo dependency, no external dependencies or server processes required.
redb is a database library written in Rust that you embed directly into your application. An embedded database means there is no separate database server to install or manage. Your program links to redb and uses it to store and retrieve data, all within the same process. The data lives in a single file on disk. The core storage model uses a B+ tree (a data structure commonly used in databases). Data is stored as key-value pairs, meaning every piece of information has a unique key and an associated value, like entries in a dictionary. The library is ACID-compliant, which means each transaction either fully succeeds or fully fails, data written to disk survives a crash, and concurrent access from multiple threads is handled safely. A notable design choice is MVCC, which stands for multi-version concurrency control. This lets multiple readers operate at the same time without blocking the writer, and without the writer blocking the readers. Each reader sees a consistent point-in-time snapshot of the data. The library also supports savepoints and rollbacks within a transaction, letting you undo partial work before committing. The README includes a short code example: create a database file, define a typed table, open a write transaction, insert a key-value pair, commit, then open a read transaction and retrieve the value. Tables are typed at compile time, so the Rust compiler checks that keys and values match the declared types. Benchmarks in the README compare redb against other embedded databases including lmdb, rocksdb, sled, fjall, and SQLite. redb is fastest at individual writes and competitive across most other workloads. lmdb is faster for bulk loads and random reads. rocksdb produces the most compact on-disk files. The file format is described as stable, meaning data stored by current versions will continue to work with future releases. The library is available under your choice of MIT or Apache 2.0 license.
← cberner on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.