-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3ba0cc
commit a8f33a6
Showing
5 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "rocksdb-example" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
rocksdb = "0.21.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use rocksdb::{Options, DB}; | ||
|
||
fn main() { | ||
println!("Hello, world!"); | ||
let path = "rocksdb-example/data"; | ||
{ | ||
let db = DB::open_default(path).unwrap(); | ||
db.put(b"name", b"sahil").unwrap(); | ||
for i in 0..1000 { | ||
db.put(String::from(i.to_string()), b"sahil").unwrap(); | ||
if i % 100 == 0 { | ||
println!("{} records inserted ..", i); | ||
} | ||
} | ||
match db.get(b"name") { | ||
Ok(Some(value)) => println!("found value: {}", String::from_utf8(value).unwrap()), | ||
Ok(None) => println!("value not found"), | ||
Err(e) => println!("operational problem encountered: {}", e), | ||
} | ||
db.delete(b"name").unwrap(); | ||
} | ||
let _ = DB::destroy(&Options::default(), path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,5 +20,9 @@ | |
"[toml]": { | ||
"editor.defaultFormatter": "tamasfe.even-better-toml" | ||
}, | ||
"cSpell.words": [ | ||
"rocksdb", | ||
"saka" | ||
], | ||
} | ||
} |