Crates.io | caves |
lib.rs | caves |
version | 0.2.1 |
source | src |
created_at | 2020-03-04 08:23:46.611156 |
updated_at | 2021-04-15 07:56:48.289279 |
description | A collection of embedded, thread-safe key-value stores in Rust. |
homepage | https://github.com/apyrgio/caves |
repository | https://github.com/apyrgio/caves |
max_upload_size | |
id | 215269 |
size | 43,044 |
A collection of embedded, thread-safe key-value stores (kvs) in Rust.
The caves
crate provides a selection of key-value stores with the
following features:
You can find more info on the rationale behind this crate on https://docs.rs/caves.
use caves::errors::Error;
use caves::{MemoryCave, Cave};
// Initialize a MemoryCave object.
let b = MemoryCave::new();
// Create a new key with an empty value.
b.set("key", b"");
// Override the key's value.
b.set("key", b"value");
// Retrieve the contents of the key.
let res = b.get("key");
assert_eq!(res.unwrap(), b"value");
// Delete the key.
b.delete("key");
// Subsequent attempts to retrieve the contents of the key should return an
// error.
let res = b.get("key");
assert_eq!(res, Err(Error::NotFound("key".to_string())));
The above example uses an in-memory backend, but there is also support for
filesystem and RocksDB backends. The latter can be enabled by passing the
with-rocksdb
feature flag for the caves
dependency in your Cargo.toml
.
You can read the latest docs in https://docs.rs/caves.
You can read the CONTRIBUTING.md
guide for more info on how to contribute to
this project.
Licensed under MPL-2.0. Please read the NOTICE.md
and LICENSE
files for
the full copyright and license information.