Skip to content

domcorvasce/rcask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rcask

rcask is a Bitcask clone written in Rust.

Getting started

Create or open a store

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.

Configuration options

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

Writing and reading data

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<()>

License

rcask is released under the MIT License

About

Bitcask clone written in Rust.

Topics

Resources

License

Stars

Watchers

Forks

Contributors