Expand description
Clock-sweep block cache. Fixed capacity. Constant-time eviction.
Slots form a ring. Each slot has a referenced bit. On insert, if the cache is full, the hand walks the ring: if the slot’s referenced bit is set, clear it; if not, evict that slot. Reads set the referenced bit on the hit slot. This is the second-chance variant of LRU - fewer per-op pointer-chasing costs, near-LRU eviction quality.
use subms_block_cache::BlockCache;
let mut c: BlockCache<u32, &'static str> = BlockCache::with_capacity(4);
c.put(1, "one");
c.put(2, "two");
assert_eq!(c.get(&1), Some(&"one"));Full writeup, design notes and measured benchmarks: https://www.submillisecond.com/cookbook/recipes/subms-block-cache
Re-exports§
pub use features::arc::ArcCache;pub use features::concurrent_shards::ShardedCache;pub use features::metrics::CacheMetrics;pub use features::metrics::MetricsCache;pub use features::tinylfu::TinyLfuCache;pub use features::weighted::WeightedCache;
Modules§
- features
- Opt-in feature catalog. Each submodule is gated by its own Cargo feature flag and adds a specific capability to the base block cache without bloating the core build.
- recipe
SubMsRecipeimpl.