A simple persistent key-value store that wraps HashMap
.
use rskey::Store;
use tempfile::TempDir;
let tmp_dir = TempDir::new()?;
let mut s = Store::open_or_create(&tmp_dir.path().join("data.kv"))?;
s.data.insert("key1".to_string(), "value1".to_string());
assert_eq!("value1", s.data.get("key1").unwrap());
use rskey::Store;
use tempfile::TempDir;
let tmp_dir = TempDir::new()?;
let mut s = Store::<String>::open_or_create(&tmp_dir.path().join("data.kv"))?;
s.data.insert("key1".to_string(), "value1".to_string());
s.data.insert("key2".to_string(), "value2".to_string());
for (key, value) in &s.data {
println!("{key} = ${value}");
}
A basic CLI tool is also included to list, get, and set key-value pairs.
cargo install rskey
The rskey
tool expects to find a data file named store.kv
in the current
directory. If there is no such file, one will be created as soon as you set a
key.
rskey list
key1: value1
key2: value2
rskey get key1
key1: value1
rskey set key3 value3
Current version: 0.3.0
License: MIT OR Apache-2.0