feat: add rocks db

This commit is contained in:
2020-11-09 00:10:04 +08:00
parent afb948c48c
commit 22ee698955
3 changed files with 422 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
use rocksdb::{DB, Options};
fn main() {
let path = "_path_for_rocksdb_storage";
{
let db = DB::open_default(path).unwrap();
db.put(b"my key", b"my value").unwrap();
match db.get(b"my key") {
Ok(Some(value)) => println!("retrieved value {}", String::from_utf8(value).unwrap()),
Ok(None) => println!("value not found"),
Err(e) => println!("operational problem encountered: {}", e),
}
db.delete(b"my key").unwrap();
}
let _ = DB::destroy(&Options::default(), path);
}