plain-cache
Overview
plain-cache
is a high-performance, thread-safe cache implementation that makes no use of unsafe
Rust code. It implements the S3-FIFO eviction
algorithm [see]. plain-cache
allocates
its capacity at cache instantiation time and is designed for high-throughput scenarios with minimal
contention.
Key Features
- S3-FIFO eviction: Optimal cache performance with predictable behavior
- Sharded design: Reduces lock contention for concurrent access
- Built-in metrics: Track hits, misses, evictions, and timing
- Custom hashing: Support for different hash functions
- Memory pre-allocation: Fixed capacity allocated at creation time
- API simplicity: Straightforward get/insert interface
Quick Start
use Cache;
let cache = with_capacity;
cache.insert;
assert_eq!;
Use if you need
- High performance
- Thread safety
- No usage of unsafe code
- No background threads
- Cache metrics
- Small dependency tree
- Easy-to-reason cache eviction (S3-FIFO)
- Ability to provide custom hasher
Do not use if you need
- Zero-sized types
- Lifecycle hooks
- Item weighing
- Custom eviction policies
- Time-based eviction
- Explicit cache deletions
- Memory-based capacity limits
- Cache warming strategies