Skip to content

v0.11.0

Choose a tag to compare

@josepdcs josepdcs released this 26 Nov 11:31
· 7 commits to main since this release
ad0e6de

🎲 Random Replacement Policy!

Version 0.11.0 introduces the Random eviction policy for baseline benchmarking and simple use cases:

New Features:

  • 🎲 Random Eviction Policy - Randomly evicts entries when cache is full
  • O(1) Performance - Constant-time eviction with no access tracking overhead
  • 🔒 Thread-Safe RNG - Uses fastrand for fast, lock-free random selection
  • 📊 Minimal Overhead - No order updates on cache hits (unlike LRU/ARC)
  • 🎯 Benchmark Baseline - Ideal for comparing policy effectiveness
  • 🔄 All Cache Types - Available in sync (thread-local & global) and async caches
  • 📚 Full Support - Works with limit, ttl, and max_memory attributes

Quick Start:

// Simple random eviction - O(1) performance
#[cache(policy = "random", limit = 1000)]
fn baseline_cache(x: u64) -> u64 { x * x }

// Random with memory limit
#[cache(policy = "random", max_memory = "100MB")]
fn random_with_memory(key: String) -> Vec<u8> {
    vec![0u8; 1024]
}

When to Use Random:

  • Baseline for performance benchmarks
  • Truly random access patterns
  • Simplicity preferred over optimization
  • Reducing lock contention vs LRU/LFU

What's Changed

Full Changelog: 0.10.1...0.11.0