cberner/redb

An embedded key-value database in pure Rust

Rust

4,827

1,795 commits

updated Oct 5, 2026

See the code

README

redb

CI Crates.io Documentation License dependency status

A simple, portable, high-performance, ACID, embedded key-value store.

redb is written in pure Rust and is loosely inspired by lmdb. Data is stored in a collection of copy-on-write B+trees. For more details, see the design doc

use redb::{Database, Error, ReadableDatabase, TableDefinition};

const TABLE: TableDefinition<&str, u64> = TableDefinition::new("my_data");

fn main() -> Result<(), Error> {
    let db = Database::create("my_db.redb")?;
    let write_txn = db.begin_write()?;
    {
        let mut table = write_txn.open_table(TABLE)?;
        table.insert("my_key", &123)?;
    }
    write_txn.commit()?;

    let read_txn = db.begin_read()?;
    let table = read_txn.open_table(TABLE)?;
    assert_eq!(table.get("my_key")?.unwrap().value(), 123);

    Ok(())
}

Status

Stable and maintained.

The file format is stable, and a reasonable effort will be made to provide an upgrade path if there are any future changes to it.

Features

  • Zero-copy, thread-safe, BTreeMap based API
  • Fully ACID-compliant transactions
  • MVCC support for concurrent readers & writer, without blocking
  • Crash-safe by default
  • Savepoints and rollbacks

no_std

Turning off the std feature, with experimental-api-5 on, builds redb without the standard library. It needs alloc, panic = "abort", and a target with atomic compare-and-swap -- Cortex-M3 and above, but not Cortex-M0. There is no filesystem, so storage is supplied by implementing StorageBackend and passing it to Builder::create_with_backend(). The cache_metrics, chrono_v0_4 and uuid features are unavailable.

Development

just and rootless podman are required. Toolchain setup, dependency vendoring, and cargo-deny checks may use network access without compiling project dependencies. Other development recipes continue to run on the host. Cargo build artifacts are cached in the redb-sandbox-target Podman volume; remove that volume to force a clean sandbox build.

Benchmarks

redb has similar performance to other top embedded key-value stores such as lmdb and rocksdb

redblmdbrocksdbfjallsqlite
bulk load17063ms9232ms13969ms18619ms15341ms
individual writes920ms1598ms2432ms3488ms7040ms
batch writes1595ms942ms451ms353ms2625ms
len()0ms0ms749ms1181ms30ms
random reads1138ms637ms2911ms2177ms4283ms
random reads934ms631ms2884ms2357ms4281ms
random range reads1174ms565ms2734ms2564ms8431ms
random range reads1173ms565ms2742ms2690ms8449ms
random reads (4 threads)1390ms840ms3995ms2606ms7000ms
random reads (8 threads)757ms427ms2147ms1352ms8123ms
random reads (16 threads)652ms216ms1478ms963ms23022ms
random reads (32 threads)410ms125ms1100ms576ms26536ms
removals23297ms10435ms6900ms6004ms10323ms
uncompacted size4.00 GiB2.61 GiB893.18 MiB1000.95 MiB1.09 GiB
compacted size1.69 GiB1.26 GiB454.71 MiB1000.95 MiB556.85 MiB

Source code for benchmark here. Results collected on a Ryzen 9950X3D with Samsung 9100 PRO NVMe.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

rust

Project health

Overall

5.0/10

Maintained

10/10

Code review

0/10
OpenSSF Scorecard

crates.io

Latest release

4.3.0 · Sep 15, 2026

Releases this year

8

Significant stargazers

(top 24 of 184)

Michael Klishin

2,004 followers · starred Sep 2025

jakevin

2,916 followers · starred Jul 2022

Emil Ernerfeldt

7,868 followers · starred Apr 2022

Benjamin Saunders

369 followers · starred Mar 2023

cberner/redb

An embedded key-value database in pure Rust

Rust

4,827

1,795 commits

updated Oct 5, 2026

See the code

README

redb

CI Crates.io Documentation License dependency status

A simple, portable, high-performance, ACID, embedded key-value store.

redb is written in pure Rust and is loosely inspired by lmdb. Data is stored in a collection of copy-on-write B+trees. For more details, see the design doc

use redb::{Database, Error, ReadableDatabase, TableDefinition};

const TABLE: TableDefinition<&str, u64> = TableDefinition::new("my_data");

fn main() -> Result<(), Error> {
    let db = Database::create("my_db.redb")?;
    let write_txn = db.begin_write()?;
    {
        let mut table = write_txn.open_table(TABLE)?;
        table.insert("my_key", &123)?;
    }
    write_txn.commit()?;

    let read_txn = db.begin_read()?;
    let table = read_txn.open_table(TABLE)?;
    assert_eq!(table.get("my_key")?.unwrap().value(), 123);

    Ok(())
}

Status

Stable and maintained.

The file format is stable, and a reasonable effort will be made to provide an upgrade path if there are any future changes to it.

Features

  • Zero-copy, thread-safe, BTreeMap based API
  • Fully ACID-compliant transactions
  • MVCC support for concurrent readers & writer, without blocking
  • Crash-safe by default
  • Savepoints and rollbacks

no_std

Turning off the std feature, with experimental-api-5 on, builds redb without the standard library. It needs alloc, panic = "abort", and a target with atomic compare-and-swap -- Cortex-M3 and above, but not Cortex-M0. There is no filesystem, so storage is supplied by implementing StorageBackend and passing it to Builder::create_with_backend(). The cache_metrics, chrono_v0_4 and uuid features are unavailable.

Development

just and rootless podman are required. Toolchain setup, dependency vendoring, and cargo-deny checks may use network access without compiling project dependencies. Other development recipes continue to run on the host. Cargo build artifacts are cached in the redb-sandbox-target Podman volume; remove that volume to force a clean sandbox build.

Benchmarks

redb has similar performance to other top embedded key-value stores such as lmdb and rocksdb

redblmdbrocksdbfjallsqlite
bulk load17063ms9232ms13969ms18619ms15341ms
individual writes920ms1598ms2432ms3488ms7040ms
batch writes1595ms942ms451ms353ms2625ms
len()0ms0ms749ms1181ms30ms
random reads1138ms637ms2911ms2177ms4283ms
random reads934ms631ms2884ms2357ms4281ms
random range reads1174ms565ms2734ms2564ms8431ms
random range reads1173ms565ms2742ms2690ms8449ms
random reads (4 threads)1390ms840ms3995ms2606ms7000ms
random reads (8 threads)757ms427ms2147ms1352ms8123ms
random reads (16 threads)652ms216ms1478ms963ms23022ms
random reads (32 threads)410ms125ms1100ms576ms26536ms
removals23297ms10435ms6900ms6004ms10323ms
uncompacted size4.00 GiB2.61 GiB893.18 MiB1000.95 MiB1.09 GiB
compacted size1.69 GiB1.26 GiB454.71 MiB1000.95 MiB556.85 MiB

Source code for benchmark here. Results collected on a Ryzen 9950X3D with Samsung 9100 PRO NVMe.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

rust

Project health

Overall

5.0/10

Maintained

10/10

Code review

0/10
OpenSSF Scorecard

crates.io

Latest release

4.3.0 · Sep 15, 2026

Releases this year

8

Significant stargazers

(top 24 of 184)

Michael Klishin

2,004 followers · starred Sep 2025

jakevin

2,916 followers · starred Jul 2022

Emil Ernerfeldt

7,868 followers · starred Apr 2022

Benjamin Saunders

369 followers · starred Mar 2023