https://github.com/ckampfe/kvqlite
https://github.com/ckampfe/kvqlite
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/ckampfe/kvqlite
- Owner: ckampfe
- License: bsd-3-clause
- Created: 2025-02-09T19:18:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-09T19:38:57.000Z (over 1 year ago)
- Last Synced: 2025-02-09T20:27:12.472Z (over 1 year ago)
- Language: Rust
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kvqlite
[](https://github.com/ckampfe/kvqlite/actions/workflows/rust.yml)
key/value db backed by sqlite, with two storage strategies: update-in-place, and append.
## update in place
- writes update values in place
- deletes remove the entire key/value from the database
- reads read the given key and value
```rust
let db: Db = Db::builder().in_memory().finish().await.unwrap();
db.write("hello", "world").await.unwrap();
let value: String = db.read("hello").await.unwrap().unwrap();
assert_eq!(value, "world");
```
## append
- writes append a new value that references the given key
- deletes remove the key and all associated values
- reads read the given key and the latest value associated with the given key
```rust
let db: Db = Db::builder().in_memory().finish().await.unwrap();
db.write("hello", "world").await.unwrap();
let value: String = db.read("hello").await.unwrap().unwrap();
assert_eq!(value, "world");
tokio::time::sleep(std::time::Duration::from_millis(1)).await;
db.write("hello", "joe").await.unwrap();
let value: String = db.read("hello").await.unwrap().unwrap();
assert_eq!(value, "joe");
let count = db.entries_count().await.unwrap();
assert_eq!(count, 2);
let keys_count = db.keys_count().await.unwrap();
assert_eq!(keys_count, 1);
```