/memdb

Thread-safe in-memory key-value store.

Primary LanguageRustApache License 2.0Apache-2.0

memdb

crates.io version build status downloads docs.rs docs

Thread-safe in-memory key-value store. Ideal for development and prototyping. Does not persist to disk.

Usage

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()));

Usage In Threads

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();

Installation

$ cargo add memdb

License

MIT OR Apache-2.0