Add persistent key-value storage to a Rust application without setting up or connecting to a database server.
Build a local-first app that stores user data with crash-safe writes and automatic background flushing to disk.
Scan a range of keys in sorted order to implement prefix search or paginated listings inside a Rust service.
Note: the main branch currently contains a large in-progress rewrite, so documented behavior may not match the latest code.
Sled is an embedded database written in Rust, meaning it runs inside your application rather than as a separate server you connect to. You store and retrieve data using keys and values, similar to a dictionary or a sorted map. There is no SQL, no schema to define upfront, and no separate database process to manage. You open a database file, read and write keys, and the library handles the rest. The API is designed to feel familiar to anyone who has used a sorted map in any programming language. You can insert a key-value pair, look it up, delete it, scan a range of keys in order, or watch for changes on a set of keys in real time. Sled also supports transactions, which let you read and write multiple keys together as a single all-or-nothing operation. On the reliability side, sled automatically flushes data to disk roughly every 500 milliseconds by default, so you do not lose much work if the process crashes. You can also trigger a flush manually if you need stronger guarantees. The storage engine is built with crash safety in mind, and the project uses fuzzing and formal methods to test correctness under failure scenarios. Performance is a stated goal. The internals use lock-free data structures so that multiple threads can read and write concurrently without blocking each other. The storage format is optimized for flash storage and compresses repeated key prefixes to reduce disk usage. The README notes that the main branch currently contains a large in-progress rewrite, so the documented behavior may not match the latest code exactly. The library is open source and available through the standard Rust package registry.
← spacejam on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.