24 releases

✓ Uses Rust 2018 edition

0.10.4 Mar 10, 2020
0.10.2 Sep 25, 2019
0.9.7 Jul 29, 2019
0.9.4 Mar 5, 2019
0.2.0 Mar 13, 2018

#3 in Database interfaces

Download history 3122/week @ 2019-12-02 3096/week @ 2019-12-09 2139/week @ 2019-12-16 472/week @ 2019-12-23 508/week @ 2019-12-30 2189/week @ 2020-01-06 1628/week @ 2020-01-13 1451/week @ 2020-01-20 516/week @ 2020-01-27 1740/week @ 2020-02-03 1587/week @ 2020-02-10 1046/week @ 2020-02-17 985/week @ 2020-02-24 1285/week @ 2020-03-02 972/week @ 2020-03-09 659/week @ 2020-03-16

5,851 downloads per month
Used in 10 crates (5 directly)




Travis CI Build Status Appveyor Build Status Documentation Crate

The rkv Rust crate is a simple, humane, typed key-value storage solution. It supports multiple backend engines with varying guarantees, such as LMDB for performance, or "SafeMode" for reliability.

This master branch only supports the LMDB backend. We're looking into supporting multiple backends, starting with "SafeMode" in the feature branch.

⚠️ Warning ⚠️

The LMDB backend is currently unstable and crash-prone. We're attempting to fix these crashes in bugs 1538539, 1538541 and 1550174.

To use rkv in production/release environments at Mozilla, you may do so with the "SafeMode" backend, for example:

rkv = { git = "https://github.com/mozilla/rkv", branch="safe-mode", default-features = false }
use rkv::{Manager, Rkv};
use rkv::backend::{SafeMode, SafeModeEnvironment};

let mut manager = Manager::<SafeModeEnvironment>::singleton().write().unwrap();
let shared_rkv = manager.get_or_create(path, Rkv::new::<SafeMode>).unwrap();


Instead of a branch, we suggest using a specific rev instead. For example, 4a1cc23906865626fa715fd99d98620169d3fd7b is the latest stable version for "safe-mode".

The "SafeMode` backend performs well, with two caveats: the entire database is stored in memory, and write transactions are synchronously written to disk on commit.

In the future, it will be advisable to switch to a different backend with better performance guarantees. We're working on either fixing the LMDB crashes, or offering more choices of backend engines (e.g. SQLite).


Comprehensive information about using rkv is available in its online documentation, which can also be generated for local consumption:

cargo doc --open


Build this project as you would build other Rust crates:

cargo build


There are several features that you can opt-in and out of when using rkv:

By default, db-dup-sort and db-int-key features offer high level database APIs which allow multiple values per key, and optimizations around integer-based keys respectively. Opt out of these default features when specifying the rkv dependency in your Cargo.toml file to disable them; doing so avoids a certain amount of overhead required to support them.

If you specify the backtrace feature, backtraces will be enabled in "failure" errors. This feature is disabled by default.

To aid fuzzing efforts, with-asan, with-fuzzer, and with-fuzzer-no-link configure the build scripts responsible with compiling the underlying backing engines (e.g. LMDB) to build with these LLMV features enabled. Please refer to the official LLVM/Clang documentation on them for more informatiuon. These features are also disabled by default.


Test this project as you would test other Rust crates:

cargo test

The project includes unit and doc tests embedded in the src/ files, integration tests in the tests/ subdirectory, and usage examples in the examples/ subdirectory. To ensure your changes don't break examples, also run them via the run-all-examples.sh shell script:


Note: the test fixtures in the tests/envs/ subdirectory aren't included in the package published to crates.io, so you must clone this repository in order to run the tests that depend on those fixtures or use the rand and dump executables to recreate them.


Of the various open source archetypes described in A Framework for Purposeful Open Source, the rkv project most closely resembles the Specialty Library, and we welcome contributions. Please report problems or ask questions using this repo's GitHub issue tracker and submit pull requests for code and documentation changes.

rkv relies on the latest rustfmt for code formatting, so please make sure your pull request passes the rustfmt before submitting it for review. See rustfmt's quick start for installation details.

We follow Mozilla's Community Participation Guidelines while contributing to this project.


The rkv source code is licensed under the Apache License, Version 2.0, as described in the LICENSE file.


~95K SLoC