Skip to main content

Crate bhandaar

Crate bhandaar 

Source
Expand description

§bhandaar (भंडार)

On-disk LRU/TTL file cache for Rust with cross-process concurrency via flock(2).

bhandaar (भंडार) — Hindi for “storehouse, repository”

§Features

  • LRU eviction — least recently used entries are evicted first
  • TTL support — per-entry time-to-live with lazy expiration
  • Cross-process safe — uses filock for flock(2) locking
  • Sharded design — user-defined shard count for concurrent access
  • Greedy storage — fills up to max size, evicts only when needed
  • Sidecar metadata — bincode-serialized, no central bottleneck

§Quick Start

use bhandaar::{Bhandaar, BhandaarConfig};

let cache = Bhandaar::new(BhandaarConfig {
    root: "/tmp/bhandaar".into(),
    max_size: 1024 * 1024 * 1024, // 1 GB
    shards: 16,
    default_ttl: None,
}).unwrap();

// Put data
cache.put("key1", b"hello world").unwrap();

// Get data
if let Some(data) = cache.get("key1").unwrap() {
    println!("Got {} bytes", data.len());
}

Structs§

Bhandaar
On-disk LRU/TTL file cache with cross-process concurrency.
BhandaarConfig
Configuration for creating a Bhandaar cache instance.
EntryMeta
Metadata for a cached entry, stored as a sidecar file.

Enums§

BhandaarError
Errors that can occur during cache operations.