rcask is a Bitcask clone written in Rust.
The Rcask::open method is used to create a store, or open it if it already exist:
use rcask::store::{Store, StoreOptions};
use std::path::PathBuf;
let store_path = PathBuf::from("~/.data");
let store = Store::open(&store_path, StoreOptions::default())?;The method will return a std::io::Result<Store> value.
You might have noticed that Rcask::open accepts a StoreOptions struct as second argument:
The struct specifies the configuration options that apply to a single store.
| Configuration option | Description | Default |
|---|---|---|
max_file_size |
Once a data file reaches max_data_file, it no longer accepts writes, and a new data file is opened. |
2GB |
Rcask handles keys and values as sequence of bytes (Vec<u8>).
You can use Rcask::put to write data onto the store:
let out = store.put(b"key", b"value"); // returns std:io::Result<()>If the write is successful, you can retrieve the data back using Rcask::get:
let value = store.get(b"key"); // returns std::io::Result<Vec<u8>>You can also delete data from the store using Rcask::delete:
let out = store.delete(b"key"); // returns std:io::Result<()>rcask is released under the MIT License