A Rust storage-engine library that provides an embeddable, persistent key-value store for fast storage.
RustMIT
Diagram
sequenceDiagram
autonumber
participant dakv
participant W as writer worker
participant C as compaction worker
Note over dakv: main thread
Note over W: writer thread
Note over C: compaction thread
dakv->>W: start writer worker
dakv->>C: start compaction worker
loop
W-->>W: wait for writer signal
end
loop
C-->>C: Wait for compaction signal
end
participant Log as write ahead log
participant Mem as memtable
dakv->>W: write kv record
W-->>C: maybe trigger compaction
W->>Log: write record
W->>Mem: insert into memtable
W->>dakv: send OK message
Loading
Example
use dakv::{Database,Options,ReadOptions,TestEnv,WriteOptions,DB};use std::sync::Arc;fnmain(){let db = {letmut opt = Options::default();
opt.env = Arc::new(TestEnv::default());DB::open("example_db".to_string(), opt).unwrap()};let write_opt = WriteOptions::default();
db.put(b"Red",b"Let me tell you something my friend. Hope is a dangerous thing. Hope can drive a man insane.",
write_opt.clone(),).unwrap();{let opt = ReadOptions::new();assert!(db.get(b"Red", opt.clone()).is_ok());
db.delete(b"Red", write_opt.clone()).unwrap();assert_eq!(db.get(b"Red", opt).unwrap_err().to_string(), "NotFound");}
db.put(b"Andy Dufresne",b"Remember Red, hope is a good thing, maybe the best of things, and no good thing ever dies.",
write_opt.clone(),).unwrap();}
Build
cd dakv
git submodule update --init --recursive
cargo build