Pure-Rust embedded key-value database with a BTreeMap-like API and ACID transactions
open sourceMIT OR Apache-2.0free
sled is a lightweight, high-performance embedded transactional database written in pure Rust, with an API like a thread-safe BTreeMap of byte keys to byte values. It has serializable ACID transactions across keys and keyspaces, atomic single-key operations including compare-and-swap, zero-copy reads, write batches, subscriptions to changes on key prefixes, multiple keyspaces, merge operators, range iterators, a crash-safe ID generator and optional zstd compression, on lock-free, flash-optimized log-structured storage. Its author calls it beta: the latest stable release is 0.34.7, and the main branch holds a large rewrite published as 1.0 alphas.
Problems it solves
- store key-value data on disk inside my Rust app without running a database server
- use an embedded database with ACID transactions in pure Rust
- replace RocksDB or LMDB bindings with a pure-Rust embedded store
- watch for changes to keys with a prefix in an embedded Rust database
Features
- BTreeMap-like API over byte keys and values
- Serializable ACID transactions across keyspaces
- Atomic compare-and-swap
- Zero-copy reads
- Write batches
- Subscriptions to key prefix changes
- Multiple keyspaces
- Merge operators
- Forward and reverse range iterators
- Crash-safe monotonic ID generator
View 2 more
- Optional zstd compression
- Lock-free, flash-optimized log-structured storage
Limitations
Alternatives
The same job
These do what sled does.
- RocksDB Embeddable persistent key-value store for fast storage
- LMDB Lightning Memory-Mapped Database: a tiny, crash-proof embedded key-value store
- Turso Database An in-process SQL database written in Rust, compatible with SQLite, now with a Postgres frontend too
