#key-value-store #kv #database #cli-tool #key-set #set-key #cli

bin+lib rskey

A simple persistent key-value store that wraps HashMap, with a basic CLI tool to list, get, and set key-value pairs

4 releases (2 breaking)

0.3.0 Aug 16, 2024
0.2.0 Jun 23, 2024
0.1.1 May 26, 2024
0.1.0 May 26, 2024

#1131 in Command line utilities

Download history 209/week @ 2024-05-23 35/week @ 2024-05-30 8/week @ 2024-06-06 159/week @ 2024-06-20 12/week @ 2024-06-27 14/week @ 2024-07-04 162/week @ 2024-08-15 2/week @ 2024-08-22

164 downloads per month

MIT/Apache

16KB
150 lines

Crate Docs CI Audit Maintenance

rskey

A simple persistent key-value store that wraps HashMap.

Getting started

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());

Iteration

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.

Installation

cargo install rskey

Usage

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.

Listing all data

rskey list
key1: value1
key2: value2

Getting a value by key

rskey get key1
key1: value1

Setting a key-value pair

rskey set key3 value3

Current version: 0.3.0

License: MIT OR Apache-2.0

Dependencies

~0.7–1.6MB
~34K SLoC