talira

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

  • Beta: the latest stable release is 0.34.7, and the main branch holds a large in-progress 1.0 rewrite published only as alphas.12
  • Doesn't support opening the same database from several instances at once.1

Alternatives

The same job

These do what sled does.

  1. RocksDB Embeddable persistent key-value store for fast storage
  2. LMDB Lightning Memory-Mapped Database: a tiny, crash-proof embedded key-value store
  3. Turso Database An in-process SQL database written in Rust, compatible with SQLite, now with a Postgres frontend too

Compare sled with the top 3