cache-mod 0.3.0

High-performance in-process caching with multiple eviction policies (LRU, LFU, TinyLFU, TTL, size-bounded). Async-safe, lock-minimized internals. Typed key-value API. No dependency on any external store.
Documentation

Status

Active development. Foundation milestone (0.2.0) shipped. On the path to 1.0.

The public API is not yet frozen. Pin specific versions; expect additive (and occasionally breaking) changes pre-1.0.


What it does

High-performance in-process caching with multiple eviction policies (LRU, LFU, TinyLFU, TTL, size-bounded). Async-safe, lock-minimized internals. Typed key-value API. No dependency on any external store.


Quick start

[dependencies]
cache-mod = "0.3"
use cache_mod::{Cache, LfuCache, LruCache};

// LRU — evicts the least-recently-accessed entry on overflow.
let lru: LruCache<&'static str, u32> = LruCache::new(64).expect("capacity > 0");
lru.insert("requests", 1);
assert_eq!(lru.get(&"requests"), Some(1));

// LFU — evicts the lowest-counter entry on overflow.
let lfu: LfuCache<&'static str, u32> = LfuCache::new(64).expect("capacity > 0");
lfu.insert("requests", 1);
assert_eq!(lfu.get(&"requests"), Some(1));

What's shipped

  • Cache<K, V> trait — the common read / write / evict contract.
  • LruCache<K, V> — bounded, thread-safe Least-Recently-Used cache.
  • LfuCache<K, V> — bounded, thread-safe Least-Frequently-Used cache.
  • CacheError — error type returned by constructors.

TinyLFU, TTL, and size-bounded variants land in subsequent minors. The lock-free, arena-backed rewrites of LruCache and LfuCache land in 0.5.0 without changing the public surface.


Standards

  • REPS governs every decision. See REPS.md.
  • MSRV: Rust 1.75.
  • Edition: 2024.
  • Cross-platform: Linux, macOS, Windows.

License

Dual-licensed under either of:

at your option.