Expand description
§cache-mod
HIGH-PERFORMANCE IN-PROCESS CACHING
Multiple eviction policies (LRU, LFU, TinyLFU, TTL, size-bounded). Async-safe, lock-minimized internals. Typed key-value API. No external store dependency.
§Status
The public API surface is feature-complete: the Cache trait, the
CacheError error type, and five reference cache implementations —
LruCache (Least-Recently-Used), LfuCache (Least-Frequently-Used),
TtlCache (Time-To-Live, lazy expiry), TinyLfuCache (Count-Min Sketch
admission filter + LRU main), and SizedCache (byte-bound capacity).
Lock-free, arena-backed rewrites land in 0.6.0 without changing this
public surface. The API is not yet frozen — pin exact versions until 1.0.
§Quick start
use cache_mod::{Cache, LruCache};
let cache: LruCache<&'static str, u32> = LruCache::new(64).expect("capacity > 0");
cache.insert("requests", 1);
cache.insert("errors", 0);
assert_eq!(cache.get(&"requests"), Some(1));
assert_eq!(cache.len(), 2);§License
Dual-licensed under Apache-2.0 OR MIT.
Structs§
- LfuCache
std - A bounded, thread-safe LFU cache.
- LruCache
std - A bounded, thread-safe LRU cache.
- Sized
Cache std - A cache bounded by total byte-weight rather than entry count.
- Tiny
LfuCache std - A bounded, thread-safe cache with admission control.
- TtlCache
std - A bounded, thread-safe cache with per-entry time-to-live.
Enums§
- Cache
Error - Errors produced by
cache-mod.
Constants§
- VERSION
- Crate version string, populated by Cargo at build time.
Traits§
- Cache
- The common read / write / evict contract every cache type in this crate implements.