0a80ad4a85
This updates binjs_meta and thus weedle, bindgen and thus clang-sys transitively, and the mime / mime_guess crate and thus unicase and version-check. Differential Revision: https://phabricator.services.mozilla.com/D66282 --HG-- rename : third_party/rust/lmdb-rkv-sys/tests/fixtures/testdb/lock.mdb => third_party/rust/lmdb-rkv-sys/tests/fixtures/testdb-32/lock.mdb rename : third_party/rust/mime_guess/Cargo.lock => third_party/rust/nom/Cargo.lock rename : third_party/rust/nom/src/branch.rs => third_party/rust/nom/src/branch/macros.rs rename : third_party/rust/nom/src/sequence.rs => third_party/rust/nom/src/sequence/macros.rs rename : third_party/rust/rkv-0.10.2/.cargo-checksum.json => third_party/rust/rkv-0.10.4/.cargo-checksum.json rename : third_party/rust/rkv-0.10.2/CODE_OF_CONDUCT.md => third_party/rust/rkv-0.10.4/CODE_OF_CONDUCT.md rename : third_party/rust/rkv-0.10.2/Cargo.toml => third_party/rust/rkv-0.10.4/Cargo.toml rename : third_party/rust/rkv-0.10.2/LICENSE => third_party/rust/rkv-0.10.4/LICENSE rename : third_party/rust/rkv-0.10.2/examples/README.md => third_party/rust/rkv-0.10.4/examples/README.md rename : third_party/rust/rkv-0.10.2/examples/iterator.rs => third_party/rust/rkv-0.10.4/examples/iterator.rs rename : third_party/rust/rkv-0.10.2/examples/simple-store.rs => third_party/rust/rkv-0.10.4/examples/simple-store.rs rename : third_party/rust/rkv-0.10.2/run-all-examples.sh => third_party/rust/rkv-0.10.4/run-all-examples.sh rename : third_party/rust/rkv-0.10.2/src/bin/dump.rs => third_party/rust/rkv-0.10.4/src/bin/dump.rs rename : third_party/rust/rkv-0.10.2/src/bin/rand.rs => third_party/rust/rkv-0.10.4/src/bin/rand.rs rename : third_party/rust/rkv-0.10.2/src/env.rs => third_party/rust/rkv-0.10.4/src/env.rs rename : third_party/rust/rkv-0.10.2/src/error.rs => third_party/rust/rkv-0.10.4/src/error.rs rename : third_party/rust/rkv-0.10.2/src/lib.rs => third_party/rust/rkv-0.10.4/src/lib.rs rename : third_party/rust/rkv-0.10.2/src/manager.rs => third_party/rust/rkv-0.10.4/src/manager.rs rename : third_party/rust/rkv-0.10.2/src/migrate.rs => third_party/rust/rkv-0.10.4/src/migrate.rs rename : third_party/rust/rkv-0.10.2/src/readwrite.rs => third_party/rust/rkv-0.10.4/src/readwrite.rs rename : third_party/rust/rkv-0.10.2/src/store.rs => third_party/rust/rkv-0.10.4/src/store.rs rename : third_party/rust/rkv-0.10.2/src/store/integer.rs => third_party/rust/rkv-0.10.4/src/store/integer.rs rename : third_party/rust/rkv-0.10.2/src/store/integermulti.rs => third_party/rust/rkv-0.10.4/src/store/integermulti.rs rename : third_party/rust/rkv-0.10.2/src/store/multi.rs => third_party/rust/rkv-0.10.4/src/store/multi.rs rename : third_party/rust/rkv-0.10.2/src/store/single.rs => third_party/rust/rkv-0.10.4/src/store/single.rs rename : third_party/rust/rkv-0.10.2/src/value.rs => third_party/rust/rkv-0.10.4/src/value.rs rename : third_party/rust/rkv-0.10.2/tests/integer-store.rs => third_party/rust/rkv-0.10.4/tests/integer-store.rs rename : third_party/rust/rkv-0.10.2/tests/manager.rs => third_party/rust/rkv-0.10.4/tests/manager.rs rename : third_party/rust/rkv-0.10.2/tests/multi-integer-store.rs => third_party/rust/rkv-0.10.4/tests/multi-integer-store.rs rename : third_party/rust/rkv-0.10.2/tests/test_txn.rs => third_party/rust/rkv-0.10.4/tests/test_txn.rs extra : moz-landing-system : lando |
||
---|---|---|
.. | ||
examples | ||
src | ||
tests | ||
.cargo-checksum.json | ||
CODE_OF_CONDUCT.md | ||
Cargo.lock | ||
Cargo.toml | ||
LICENSE | ||
README.md | ||
run-all-examples.sh |
README.md
rkv
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).
Use
Comprehensive information about using rkv is available in its online documentation, which can also be generated for local consumption:
cargo doc --open
Build
Build this project as you would build other Rust crates:
cargo build
Features
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
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:
./run-all-examples.sh
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.
Contribute
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.
License
The rkv source code is licensed under the Apache License, Version 2.0, as described in the LICENSE file.