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

Sled — Modern Embedded Database for Rust

A lightweight, lock-free embedded key-value store written in Rust, inspired by modern B-tree research.

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
Sled Overview
Comando CLI universal
npx tokrepo install 6678c522-5551-11f1-9bc6-00163e2b0d79

Introduction

Sled is an embedded database written in Rust that provides a concurrent, ACID-compliant key-value store. It was designed from the ground up to leverage modern hardware with lock-free data structures, making it suitable for applications that need high-throughput embedded storage without an external database process.

What Sled Does

  • Provides a zero-config embedded key-value store with ACID transactions
  • Supports ordered iteration, range scans, and prefix scanning
  • Offers merge operators for conflict-free concurrent value updates
  • Delivers crash-safe storage through write-ahead logging
  • Enables structured data through typed trees and namespaced keyspaces

Architecture Overview

Sled uses a lock-free B+ tree variant called a Bw-tree for its core index structure. Writes go through a write-ahead log for durability, and background compaction reclaims space. The page cache uses epoch-based reclamation to avoid locks, and the storage engine is designed around flash-friendly I/O patterns to minimize write amplification.

Self-Hosting & Configuration

  • Add sled as a Cargo dependency; no external process or server needed
  • Configure cache size, flush interval, and compression via the sled::Config builder
  • Use temporary mode for testing to avoid writing to disk
  • Set segment size and snapshot thresholds for write-heavy workloads
  • Monitor database statistics through the built-in sled::Db::size_on_disk method

Key Features

  • Lock-free concurrent reads and writes using modern B-tree research
  • Built-in ACID transactions with serializable isolation
  • Zero external dependencies beyond the Rust standard library
  • Merge operators for conflict-free counters and append-only logs
  • Subscribes to key-change events for reactive application patterns

Comparison with Similar Tools

  • RocksDB — RocksDB is C++ with Rust bindings; sled is pure Rust with a simpler API
  • SQLite — SQLite provides relational SQL; sled is a key-value store for structured Rust data
  • LevelDB — LevelDB is read-optimized; sled targets balanced read/write workloads with concurrency
  • redb — redb is a newer Rust embedded DB focused on simplicity; sled offers more features like subscribers
  • LMDB — LMDB uses memory-mapped files; sled uses a log-structured approach with compaction

FAQ

Q: Is sled production-ready? A: Sled is widely used but still pre-1.0. The API is stable for the 0.34 line, and the author is working on a 1.0 rewrite with improved performance.

Q: Does sled support multi-process access? A: No. Sled is designed for single-process, multi-threaded use. Use a client-server database if you need multi-process access.

Q: How does sled handle crash recovery? A: Sled uses write-ahead logging and periodic snapshots to recover to a consistent state after unexpected shutdowns.

Q: Can sled be used in WebAssembly? A: Not directly, since sled depends on filesystem I/O. It is designed for native Rust applications.

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