v0.10.0
💾 Memory-Based Limits!
Version 0.10.0 introduces memory-aware caching controls:
New Features:
- 💾 Memory-Based Limits - Control cache size by memory footprint
- 📏
max_memoryAttribute - Specify memory limit (e.g.max_memory = "100MB") - 🔄 Combined Limits - Use both entry count and memory limits together
- ⚙️ Custom Memory Estimation - Implement
MemoryEstimatorfor precise control - 📊 Improved Statistics - Monitor memory usage and hit/miss rates together
Breaking Changes:
- Default policy remains LRU - No change, but now with memory limits!
- MemoryEstimator usage - Custom types with heap allocations must implement
MemoryEstimator
Quick Start:
// Memory limit - eviction when total size exceeds 100MB
#[cache(max_memory = "100MB")]
fn large_object(id: u32) -> Vec<u8> {
vec![0u8; 512 * 1024] // 512KB object
}
// Combined limits - max 500 entries OR 128MB
#[cache(limit = 500, max_memory = "128MB")]
fn compute(x: u64) -> u64 { x * x }What's Changed
Full Changelog: 0.9.0...0.10.0