Block cache - Rust
Clock-sweep block cache with constant-time eviction. Approximates LRU; pays one hash probe + one slot bump per get.
Part of the submillisecond.com cookbook. Zero external dependencies; std only.
Install
[]
= "0.4"
Quickstart
Public API
pub struct BlockCache<K, V>pub fn with_capacity(capacity: usize) -> Selfpub fn capacity(&self) -> usizepub fn len(&self) -> usizepub fn is_empty(&self) -> boolpub fn get(&mut self, key: &K) -> Option<&V>pub fn put(&mut self, key: K, value: V) -> Option<(K, V)>
Files
src/lib.rs- implementation.tests/- integration tests; correctness, edge cases, property/stress.examples/demo.rs- stdout walkthrough.examples/perf_main.rs- bench entry (behind theharnessfeature).
License
Dual-licensed under MIT OR Apache-2.0.