rcask

Crates.iorcask
lib.rsrcask
version0.1.0
created_at2025-05-29 13:15:34.75831+00
updated_at2025-05-29 13:15:34.75831+00
descriptionBitcask inspired in-memory log structured hash table.
homepagehttps://github.com/Ashwin-1709/rcask
repositoryhttps://github.com/Ashwin-1709/rcask
max_upload_size
id1693762
size18,772
Ashwin Pugalia (Ashwin-1709)

documentation

README

rcask

crates.io Build Passing

rcask is a bitcask inspired, rust-based in-memory key-value store built on the core concepts of log-structured storage engines.


What does it have?

  • In-Memory Index: Key value lookups are supported through HashMap that stores the exact disk offset for each key.
  • Log-Structured Persistence: Data is appended to a file in a sequential "log" fashion.
  • Compaction: Automatically compacts log files after a configurable number of writes to keep disk usage under control.
  • Data Integrity: Keys are read and validated during retrieval to help detect potential data corruption.
  • Storage APIs set and get operations for storing and retrieving string-based key-value pairs.
  • Crash Recovery: The in-memory index is rebuilt from the log file upon initialization, ensuring data persistence across application restarts.

Examples

use rcask::RCask;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
    let mut store = RCask::init(
        "./".to_string(), // Directory to store logs
        "log".to_string(), // Pattern for log files
        3)?; // Maximum number of writes before compaction

    // Default store with max_writes as 10000 before compaction
    let mut default_store = RCask::new(
        "./".to_string(), // Directory to store logs
        "default_log".to_string(), // Pattern for log files
    )?;

    store.set("key1", "value1")?;
    store.set("key2", "value2")?;
    store.set("key3", "value3")?;

    println!("Value for key1: {:?}", store.get("key1")?);
    println!("Value for key2: {:?}", store.get("key2")?);
    println!("Value for key3: {:?}", store.get("key3")?);

    store.set("key1", "response: { values: ['A', 'B', 'C'] } ")?;
    println!("Updated value for key1: {:?}", store.get("key1")?);

    return Ok(());
}
Commit count: 5

cargo fmt