Skip to main content


rust sled A (beta) modern embedded database


sled - it's all downhill from here!!!
https://github.com/spacejam/sled

A (beta) modern embedded database. Doesn't your data deserve a (beta) beautiful new home?

let tree = sled::open("/tmp/welcome-to-sled").expect("open");

// insert and get, similar to std's BTreeMap
tree.insert("KEY1", "VAL1");
assert_eq!(tree.get(&"KEY1"), Ok(Some(sled::IVec::from("VAL1"))));

// range queries
for kv in tree.range("KEY1".."KEY9") {}

// deletion
tree.remove(&"KEY1");

// atomic compare and swap
tree.compare_and_swap("KEY1", Some("VAL1"), Some("VAL2"));

// block until all operations are stable on disk
// (flush_async also available to get a Future)
tree.flush();
If you would like to work with structured data without paying expensive deserialization costs, check out the structured example!

performance
LSM tree-like write performance with traditional B+ tree-like read performance
over a billion operations in under a minute at 95% read 5% writes on 16 cores on a small dataset
measure your own workloads rather than relying on some marketing for contrived workloads
what's the trade-off? sled uses too much disk space sometimes. this will improve significantly before 1.0.

features
API similar to a threadsafe BTreeMap<[u8], [u8]>
serializable multi-key and multi-Tree interactive transactions
fully atomic single-key operations, supports compare and swap
zero-copy reads
write batch support
subscriber/watch semantics on key prefixes
multiple keyspace/Tree support
merge operators
forward and reverse iterators
a crash-safe monotonic ID generator capable of generating 75-125 million unique ID's per second
zstd compression (use the compression build feature)
cpu-scalable lock-free implementation
flash-optimized log-structured storage
uses modern b-tree techniques such as prefix encoding and suffix truncation for reducing the storage costs of long keys