Expand description
§emdb
A lightweight, high-performance embedded database for Rust.
This crate provides an in-memory key/value store with optional TTL handling and nested-key ergonomics.
The API is still pre-1.0 and may change. See the repository for roadmap and status: https://github.com/jamesgober/emdb-rs
§Examples
Base key/value usage:
use emdb::Emdb;
let mut db = Emdb::open_in_memory();
db.insert("name", "emdb")?;
assert_eq!(db.get("name")?, Some(b"emdb".to_vec()));Persistent usage:
use emdb::Emdb;
let path = std::env::temp_dir().join("emdb-doc-example.emdb");
{
let mut db = Emdb::open(&path)?;
db.insert("name", "emdb")?;
db.flush()?;
}
let db = Emdb::open(&path)?;
assert_eq!(db.get("name")?, Some(b"emdb".to_vec()));TTL usage:
use std::time::Duration;
use emdb::{Emdb, Ttl};
let mut db = Emdb::builder()
.default_ttl(Duration::from_secs(60))
.build()?;
db.insert_with_ttl("session", "token", Ttl::Default)?;
assert!(db.ttl("session")?.is_some());Nested usage:
use emdb::Emdb;
let mut db = Emdb::open_in_memory();
let mut profile = db.focus("profile");
profile.set("name", "james")?;
assert_eq!(profile.get("name")?, Some(b"james".to_vec()));Structs§
- Emdb
- The primary embedded database handle.
- Emdb
Builder - Builder for constructing an in-memory
Emdbinstance. - Focus
nested - Scoped database view that prefixes keys with a dotted path segment.
Enums§
- Error
- The top-level error type returned by every fallible operation in
emdb. - Flush
Policy - Flush durability policy for file-backed storage.
- Ttl
- Time-to-live specification for a record.