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
filockforflock(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.
- Bhandaar
Config - Configuration for creating a Bhandaar cache instance.
- Entry
Meta - Metadata for a cached entry, stored as a sidecar file.
Enums§
- Bhandaar
Error - Errors that can occur during cache operations.