durableMap
durableMap is in-memory, durable storage
optimized for ( write-heavy, read-heavy )
Why need to DurableMap ??
it is a concurrent hashMap using NonBlocking wal engine for persist to disk
it avoid any loss data
Example
#[tokio::main]
async fn main() {
let dlw = WConcurrentStorage::<Document>::open("tester".to_owned(), 1000).await;
let dlr = RConcurrentStorage::<Document>::open("tester".to_owned(), 1000).await;
let _ = dlr.insert_entry(format!("102xa"), Document::new()).await;
let _ = dlw.insert_entry(format!("102xa"), Document::new()).await;
dlr.remove_entry(&format("102xa")).await;
dlw.remove_entry(&format("102xa")).await;
dlr.table.read().await
.iter()
.for_each(|(key, doc)| {
println!("==> {} -> {}", key, &doc.funame)
});
dlw.table
.iter()
.for_each(|(key, doc)| {
println!("==> {} -> {}", key, &doc.funame)
});
}
#[derive(Serialize, Deserialize, Clone)]
struct Document {
funame: String,
age: i32,
}
impl Document {
pub fn new() -> Self {
Document {
funame: String::from("DanyalMh"),
age: 24,
}
}
}
Installation
[dependencies]
rstorage = "1.0.2"