Thread-safe in-memory key-value store. Ideal for development and prototyping. Does not persist to disk.
extern crate memdb;
use memdb::Memdb;
let mut db = Memdb::default();
db.set("beep".into(), "boop".into());
let val = db.get("beep".into());
assert_eq!(val, Some("boop".to_string()));
To use the database inside a thread, call .clone()
on it and move
the
result.
let db = Memdb::default();
let mut db_handle = db.clone();
let t = thread::spawn(move || {
db_handle.set("beep".into(), "boop".into());
});
t.join().unwrap();
$ cargo add memdb
MIT OR Apache-2.0