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
[]
= "0.5"
use Duration;
use ;
// LRU — evicts the least-recently-accessed entry on overflow.
let lru: = new.expect;
lru.insert;
assert_eq!;
// LFU — evicts the lowest-counter entry on overflow.
let lfu: = new.expect;
lfu.insert;
// TTL — entries expire after their per-entry deadline; lazy expiry on access.
let ttl: =
new.expect;
ttl.insert_with_ttl;
// TinyLFU — Count-Min Sketch admission filter rejects cold candidates.
let tinylfu: = new.expect;
tinylfu.insert;
// SizedCache — capacity is total byte-weight, not entry count.
let sized: =
new.expect;
sized.insert;
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.TtlCache<K, V>— bounded, thread-safe Time-To-Live cache with lazy expiry.TinyLfuCache<K, V>— Count-Min Sketch admission filter + LRU main cache.SizedCache<K, V>— capacity bound is total byte-weight across entries.CacheError— error type returned by constructors.
Lock-free, arena-backed rewrites of the existing reference implementations land in 0.6.0 — public surface unchanged.
Documentation
- API Reference — every public item, with signature, contract, and code examples.
- Docs index — release archive + quick links.
- CHANGELOG — per-version diff log.
- REPS standards — quality discipline this crate is held to.
- Machine-rendered rustdoc: docs.rs/cache-mod.
Standards
- REPS governs every decision. See REPS.md.
- MSRV: Rust 1.75.
- Edition: 2021.
- Cross-platform: Linux, macOS, Windows.
License
Dual-licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.