Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsMay 21, 2026·3 min de lecture

Redb — Simple Embedded Key-Value Store in Pure Rust

A lightweight, ACID-compliant embedded key-value database written in pure Rust with zero unsafe code and a B-tree based storage engine.

Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Redb Overview
Commande CLI universelle
npx tokrepo install eb969dda-5551-11f1-9bc6-00163e2b0d79

Introduction

Redb is an embedded key-value store written entirely in safe Rust. It was designed as a modern alternative to LMDB and sled, prioritizing correctness, simplicity, and safety. The codebase uses zero unsafe blocks, relying on Rust's type system and borrow checker to prevent memory bugs while still delivering competitive read and write performance.

What Redb Does

  • Provides ACID-compliant transactions with serializable isolation
  • Stores typed key-value pairs in named tables within a single database file
  • Supports range queries, prefix scans, and reverse iteration over ordered keys
  • Offers multimap tables where a single key can map to multiple values
  • Handles crash recovery automatically with no manual repair tools needed

Architecture Overview

Redb uses a copy-on-write B-tree for its core storage structure. Writes create new tree pages rather than modifying existing ones, and a two-phase commit ensures atomicity. The database file uses a custom allocator that tracks free pages for reuse. All I/O goes through Rust's standard library with no mmap or unsafe FFI, making the codebase auditable and safe by construction.

Self-Hosting & Configuration

  • Add redb as a Cargo dependency; no external services or build tools required
  • Create a database by specifying a file path; the file is created automatically
  • Define table schemas at compile time using the TableDefinition type
  • Configure cache size and durability mode through the Database builder API
  • Use in-memory mode for testing by creating a database without a file path

Key Features

  • Zero unsafe code provides strong memory safety guarantees
  • MVCC readers never block writers and vice versa
  • Typed tables catch key-value type mismatches at compile time
  • Multimap tables natively support one-to-many relationships
  • Savepoints allow rolling back to intermediate points within a transaction

Comparison with Similar Tools

  • sled — sled uses lock-free structures for concurrency; redb uses a simpler copy-on-write B-tree with zero unsafe code
  • LMDB — LMDB is C with memory-mapped I/O; redb is pure safe Rust with standard file I/O
  • RocksDB — RocksDB is a C++ LSM-tree engine; redb is a simpler B-tree store for moderate workloads
  • SQLite — SQLite is a relational database; redb is a lower-level key-value store with typed tables
  • bbolt — bbolt is a Go embedded database; redb is the Rust equivalent with a similar B-tree design

FAQ

Q: Is redb production-ready? A: Yes. Redb reached version 1.0 and later 2.0 with a stable API. It is used in production by several projects including the Ordinals Bitcoin indexer.

Q: How does redb compare to sled in performance? A: Redb is generally competitive with sled on read-heavy workloads and can be faster for write-heavy workloads due to its simpler architecture. Benchmarks vary by use case.

Q: Does redb support concurrent access from multiple threads? A: Yes. Multiple readers can run concurrently with a single writer. Readers see a consistent snapshot and are never blocked by writes.

Q: Can redb handle large datasets? A: Redb supports databases up to several terabytes. The B-tree structure provides logarithmic lookup times regardless of dataset size.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires