About this project

sled is an embedded database written in Rust, described by its author as beta software. Its API resembles a threadsafe BTreeMap<[u8], [u8]>, so basic insert, get, range, remove and compare-and-swap operations feel familiar to Rust developers. Key capabilities listed in the README include serializable ACID transactions for atomically reading and writing multiple keys across multiple keyspaces, fully atomic single-key operations, zero-copy reads, write batches, subscriptions to changes on key prefixes, multiple keyspaces, merge operators, forward and reverse range iterators, and a crash-safe monotonic ID generator. Optional zstd compression is available behind a build feature that is disabled by default. The implementation is described as a lock-free tree on a lock-free pagecache on a lock-free log, with a flash-optimized log-structured storage design. It uses b-tree techniques such as prefix encoding and suffix truncation to reduce storage costs for long keys with shared prefixes. The README claims LSM-tree-like write performance with traditional B+ tree-like read performance, and notes that durability defaults to an fsync every 500ms, configurable via flush_every_ms or manual flush/flush_async calls. Notable caveats: transactions are optimistic, so transaction closures should avoid external state or IO unless idempotent; sled does not support multiple open instances, so it should stay open for the process lifetime; numerical keys should be stored big-endian for correct lexicographic ordering; and the on-disk format is expected to change before 1.0.0, requiring manual migrations. The README also states that SQLite is preferable when reliability is the primary constraint, RocksDB when storage price performance matters, and LMDB for multi-process workloads that rarely write. The minimum supported Rust version is 1.62.