Esta página se muestra en inglés. Una traducción al español está en curso.
ConfigsMay 21, 2026·3 min de lectura

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.

Listo para agents

Este activo puede ser leído e instalado directamente por agents

TokRepo expone un comando CLI universal, contrato de instalación, metadata JSON, plan según adaptador y contenido raw para que los agents evalúen compatibilidad, riesgo y próximos pasos.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
Redb Overview
Comando CLI universal
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

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados