fibre_cache is a concurrent in-memory cache for Rust with the same API shape for sync and async code. You build it with CacheBuilder and get back either a Cache for blocking code or an AsyncCache for async code. to_sync() and to_async() switch between the two handles at no cost.
It covers the jobs a cache usually ends up doing in a real service: a capacity measured in cost units, time-to-live and time-to-idle expiry plus a loader that fills misses for you and runs only once when many callers miss the same key at the same time. Stale-while-revalidate, an eviction listener, an atomic entry API, bulk operations and serde snapshots are there when you need them.
Values are stored behind an Arc, so V does not have to implement Clone. Reads hand back an Arc<V>. If you only need to look at the value, get runs a closure against it in place. The cache is split into shards with their own locks and eviction state. A background janitor does the cleanup work so reads and writes stay short. The default policy for a bounded cache is TinyLFU. SIEVE, SLRU, ARC, LRU, Clock, FIFO and random are available as alternatives.
use Duration;
use CacheBuilder;
let cache = default
.capacity
.time_to_live
.async_loader
.build_async?;
let name = cache.fetch_with.await;