6 releases
Uses new Rust 2024
| 0.2.2 | Jul 6, 2025 |
|---|---|
| 0.2.1 | Jul 6, 2025 |
| 0.1.2 | Jun 13, 2025 |
#131 in Caching
221 downloads per month
39KB
752 lines
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 plain_cache::Cache;
let cache = Cache::with_capacity(1000);
cache.insert("key", "value");
assert_eq!(cache.get("key"), Some("value"));
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
Dependencies
~1–1.5MB
~24K SLoC