ferrumdb 0.0.1

A premium, high-performance embedded key-value database with TTL and compaction.
Documentation

๐Ÿ›ก๏ธ FerrumDB


FerrumDB is a premium, high-performance local key-value database built in Rust. Designed for developers who need a reliable, "zero-setup" structured data store that feels as fast as a cache but is as durable as a disk-backed database.

๐ŸŒŸ Why FerrumDB?

  • โšก Append-Only Architecture (AOF): $O(1)$ write performance. We never overwriteโ€”we only grow.
  • ๐Ÿ“ฆ Structured Data: Native support for JSON Values. Store objects, arrays, and numbers directly.
  • โณ Time-To-Live (TTL): Built-in data expiration for efficient local caching.
  • ๐Ÿงน Background Compaction: Automatic garbage collection to keep your storage footprint minimal.
  • ๐Ÿ—๏ธ Embeddable Library: Use it as a CLI tool or import it as a high-level Rust crate.
  • ๐Ÿ›ก๏ธ Crash Resilient: Atomic swaps and sync_data guarantee your data survives power loss.

๐Ÿš€ Quick Start

Library Usage (Zero-Setup)

Add FerrumDB to your project and start storing data in seconds:

use ferrumdb::FerrumDB;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Zero-setup open (defaults to ./ferrum.db)
    let db = FerrumDB::open_default().await?;

    // Store structured JSON
    db.set("user:1".into(), json!({
        "name": "Usman",
        "role": "Premium Developer"
    })).await?;

    // Retrieve data
    if let Some(user) = db.get("user:1").await {
        println!("User: {}", user["name"]);
    }

    Ok(())
}

CLI Interactive REPL

Experience the premium terminal interface with autocomplete and syntax highlighting:

cargo run --release

๐Ÿ› ๏ธ Commands Reference

Command Usage Description
SET SET <key> <json> Store structured data (Strings, Objects, Arrays)
GET GET <key> Retrieve and pretty-print stored data
DELETE DELETE <key> Remove a key-value pair
KEYS KEYS List all indexed keys
COUNT COUNT Show total number of entries
COMPACT COMPACT Manually trigger log file optimization
HELP HELP Show commands and session metrics

๐ŸŽจ Premium REPL Features

  • Tab-Complete: Instantly complete commands and keys.
  • Colorized Output: High-contrast, easy-to-read terminal feedback.
  • JSON Pretty-Print: Structured output for complex data.

๐Ÿ“ Architecture

  • Engine: Bitcask-lite inspired log-structured storage.
  • Index: In-memory HashMap leveraging tokio::sync::RwLock for high concurrency.
  • Persistence: Binary serialization via bincode for maximum speed and minimal disk usage.

๐Ÿ“ License

Distributed under the MIT License. See LICENSE for more information.