Crate tinykv

Source
Expand description

§TinyKV

A minimal JSON-based persistent key-value store for Rust projects. Supports optional TTL (expiration), auto-saving, backup, and serialization via serde.

§Features

  • File-based storage using pretty-formatted JSON
  • Optional TTL expiration support per key
  • Auto-saving changes on modification
  • Backup support with .bak files
  • Simple interface with serde for value types

§Example

use tinykv::TinyKV;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut kv = TinyKV::open("mydata.json")?.with_auto_save();
    kv.set("username", "hasan")?;
    kv.set_with_ttl("session_token", "abc123", 60)?; // 60 seconds TTL
    let user: Option<String> = kv.get("username")?;
    println!("User: {:?}", user);
    Ok(())
}

Structs§

TinyKV
A simple persistent key-value store with TTL and auto-save.

Enums§

TinyKVError
Errors that can occur while using the TinyKV store.