Skip to main content

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 mmap'ed, copy-on-write, B-trees. For more details, see the design doc

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

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

fn main() -> Result<(), Error> {
    let db = unsafe { Database::create("my_db.redb", 1024 * 1024)? };
    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(), 123);

    Ok(())
}

Status

redb is undergoing active development, and should be considered beta quality. It may eat your data, and does not have any guarantees of file format stability :)

Features

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

Roadmap

The following features are planned before the 1.0 release

  • Stable file format
  • User-defined zero-copy types

Benchmarks

redb is nearly as fast as lmdb, and faster than sled, on many benchmarks

+--------------------+--------------+------------+--------+---------+---------+
|                    | redb (1PC+C) | redb (2PC) | lmdb   | rocksdb | sled    |
+=============================================================================+
| bulk load          | 1770ms       | 1370ms     | 976ms  | 5263ms  | 4534ms  |
|--------------------+--------------+------------+--------+---------+---------|
| individual writes  | 227ms        | 381ms      | 388ms  | 701ms   | 642ms   |
|--------------------+--------------+------------+--------+---------+---------|
| batch writes       | 2346ms       | 2533ms     | 2136ms | 992ms   | 1395ms  |
|--------------------+--------------+------------+--------+---------+---------|
| large writes       | 8805ms       | 6532ms     | 7793ms | 21475ms | 37736ms |
|--------------------+--------------+------------+--------+---------+---------|
| random reads       | 734ms        | 734ms      | 642ms  | 5814ms  | 1514ms  |
|--------------------+--------------+------------+--------+---------+---------|
| random range reads | 832ms        | 834ms      | 712ms  | 6074ms  | 1826ms  |
|--------------------+--------------+------------+--------+---------+---------|
| removals           | 1281ms       | 1149ms     | 676ms  | 2481ms  | 1792ms  |
+--------------------+--------------+------------+--------+---------+---------+

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.

Metadata

Release files for redb 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redb 0.5.0
File Size Uploaded Provenance Actions
redb-0.5.0.tar.gz 101.6 kB Without provenance Details for redb-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for redb 0.5.0
File Interpreter ABI Platform Actions
redb-0.5.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 abi3 Linux glibc 2.17+ x86-64 Details for redb-0.5.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Total release size: 269.9 kB

Release files / redb-0.5.0.tar.gz

Download URL redb-0.5.0.tar.gz
Size 101.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a9b0e600f0f5e0c2bfef118b778253c5ef604926d4f61649a009cfe492bd1cef
BLAKE2b-256 checksum
How to use checksums
c4e7402d3b62a330acad19b14350429694edbc3ce4d8339d9ff12593fecc455d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.1

Release files / redb-0.5.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL redb-0.5.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 168.3 kB
Tags CPython 3.7 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
330a196034bdb255cbbf84b4296ca76782956ff2351adda060c95da75c501102
BLAKE2b-256 checksum
How to use checksums
d59a2ef1ccf219d7abe5e509f28242a56e73e6e4f878ca4072c729aa8cd4a1a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.1

Security for redb 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page