Skip to content

pantShrey/bitcask_impl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kvs

kvs is a persistent, log-structured key-value store implemented in Rust. Inspired by Bitcask, it utilizes an in-memory hash map for indexing and append-only log files for persistent storage with crash recovery capabilities.

Features

  • Log-Structured Storage: Fast writes using append-only logs.
  • In-Memory Indexing: Fast lookups using HashMap.
  • Data Persistence: Serde-based serialization guarantees data survives restarts.
  • Automatic Compaction: Reclaims space by removing stale data when logs grow too large.
  • CLI Utility: Easy-to-use command line interface.

Installation

cargo install --path .

Usage

CLI

kvs provides a simple command-line interface:

# Set a key-value pair
kvs set <KEY> <VALUE>

# Get a value by key
kvs get <KEY>

# Remove a key
kvs rm <KEY>

Library

You can integrate kvs into your Rust application:

use kvs::KvStore;
use std::env::current_dir;

fn main() -> kvs::Result<()> {
    // Open the store in the current directory
    let mut store = KvStore::open(current_dir()?)?;

    store.set("my_key".to_owned(), "my_value".to_owned())?;
    
    if let Some(value) = store.get("my_key".to_owned())? {
        println!("Retrieved: {}", value);
    }
    
    store.remove("my_key".to_owned())?;
    
    Ok(())
}

Roadmap

Future developments and architectural improvements planned for kvs include:

  • Hint Files: Implementation of hint files to speed up the startup process by avoiding full log scanning.
  • Advanced Multi-File Compaction: Optimization of the compaction strategy to handle multiple concurrent log files more efficiently.
  • Networked Application: Transitioning from a CLI tool to a Client-Server architecture (gRPC or TCP) to allow remote access.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages