Sled – An Embedded Database in Rust
Sled is an embedded database implemented in Rust that offers a variety of features for efficient data management. It supports atomic operations, transactions, and provides a threadsafe API similar to BTreeMap. The database is designed for high performance with optimizations for storage and retrieval, making it suitable for applications requiring structured data handling.
- ▪Sled provides atomic compare and swap operations and supports serializable transactions for multiple keys.
- ▪The database automatically fsyncs every 500ms by default to ensure durability.
- ▪Sled uses modern B-tree techniques to optimize storage costs, particularly for long keys with shared prefixes.
Opening excerpt (first ~120 words) tap to expand
key value documentation chat about databases with us sled - it's all downhill from here!!! An embedded database. let tree = sled::open("/tmp/welcome-to-sled")?; // insert and get, similar to std's BTreeMap let old_value = tree.insert("key", "value")?; assert_eq!( tree.get(&"key")?, Some(sled::IVec::from("value")), ); // range queries for kv_result in tree.range("key_1".."key_9") {} // deletion let old_value = tree.remove(&"key")?; // atomic compare and swap tree.compare_and_swap( "key", Some("current_value"), Some("new_value"), )?; // block until all operations are stable on disk // (flush_async also available to get a Future) tree.flush()?; $${\color{red}This \space README \space is \space out \space of \space sync \space with \space the \space main \space branch \space which \space…
Excerpt limited to ~120 words for fair-use compliance. The full article is at GitHub.