subms-block-cache 0.4.0

submillisecond.com cookbook recipe - memory: subms-block-cache. Clock-sweep block cache with constant-time eviction.
Documentation
  • Coverage
  • 37.5%
    3 out of 8 items documented1 out of 8 items with examples
  • Size
  • Source code size: 14.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 301.89 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kdog007

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

[dependencies]
subms-block-cache = "0.4"

Quickstart

cargo test --release
cargo run --example demo

Public API

  • pub struct BlockCache<K, V>
  • pub fn with_capacity(capacity: usize) -> Self
  • pub fn capacity(&self) -> usize
  • pub fn len(&self) -> usize
  • pub fn is_empty(&self) -> bool
  • pub 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 the harness feature).

License

Dual-licensed under MIT OR Apache-2.0.