kvdb-lib

Crates.iokvdb-lib
lib.rskvdb-lib
version0.1.6
sourcesrc
created_at2024-07-10 13:33:30.989498
updated_at2024-07-11 12:29:54.254777
descriptionA simple thread-safe key-value storage library using DashMap.
homepagehttps://github.com/messengernew/kvdb-lib
repositoryhttps://github.com/messengernew/kvdb-lib
max_upload_size
id1298251
size7,036
monkaCat.jar | MeSSengeR.py (messengernew)

documentation

https://docs.rs/kvdb_lib

README

Key: Value database library

A simple thread-safe key-value storage library using DashMap.

Usage

Add kvdb-lib to your Cargo.toml:

[dependencies]
kvdb-lib = "0.1.6"

Add the following to your main file:

use kvdb_lib::Storage;

fn main() {
    let storage = Storage::new();
    storage.set(1, "value1");
    println!("{:?}", storage.get(&1));
}

Examples

Creating a Storage

Create a new Storage instance:

use kvdb_lib::Storage;

let storage: Storage<i32, &str> = Storage::new();

Setting a Key-Value Pair

Insert a key-value pair:

use kvdb_lib::Storage;

let storage = Storage::new();
storage.set(1, "value1");

Getting a Value

Retrieve a value by its key:

use kvdb_lib::Storage;

let storage = Storage::new();
storage.set(1, "value1");

assert_eq!(storage.get(&1), Some("value1"));

Removing a Key-Value Pair

Remove a key-value pair:

use kvdb_lib::Storage;

let storage = Storage::new();
storage.set(1, "value1");
storage.remove(1);

assert_eq!(storage.get(&1), None);

Getting All Key-Value Pairs

Retrieve all key-value pairs:

use kvdb_lib::Storage;

let storage = Storage::new();

storage.set(1, "value1");
storage.set(2, "value2");
let all = storage.get_all();

assert!(all.contains(&(1, "value1")));
assert!(all.contains(&(2, "value2")));

License

This project is licensed under the MIT License.

Commit count: 21

cargo fmt