#embedded #persistence #database #key-value-store

caves

A collection of embedded, thread-safe key-value stores in Rust

3 unstable releases

0.2.1 Apr 15, 2021
0.2.0 Apr 13, 2021
0.1.0 Mar 4, 2020

#161 in Database implementations

Download history 9/week @ 2023-02-08 19/week @ 2023-02-15 20/week @ 2023-02-22 4/week @ 2023-03-01 6/week @ 2023-03-08 21/week @ 2023-03-15 65/week @ 2023-03-22 68/week @ 2023-03-29 74/week @ 2023-04-05 79/week @ 2023-04-12 64/week @ 2023-04-19 70/week @ 2023-04-26 76/week @ 2023-05-03 75/week @ 2023-05-10 65/week @ 2023-05-17 68/week @ 2023-05-24

293 downloads per month
Used in 2 crates

MPL-2.0 license

21KB
303 lines

Caves

A collection of embedded, thread-safe key-value stores (kvs) in Rust.

CI Crates.io Docs.rs

Overview

The caves crate provides a selection of key-value stores with the following features:

  • Embedded
  • Thread-safe
  • Simple API; get/set/delete a key
  • Dev-friendly

You can find more info on the rationale behind this crate on https://docs.rs/caves.

Usage

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.

Documentation

You can read the latest docs in https://docs.rs/caves.

Contributing

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.

Dependencies

~0.7–10MB
~186K SLoC