Skip to content

cache

Caches and stores: entries that expire with a passed-in clock (ExpiringMap), and a capacity-bounded map that evicts by recency instead (LruCache). Neither ever reads a clock or the system allocator’s notion of “recent” behind the caller’s back.

Cargo feature cache (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features cache

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.7", default-features = false, features = ["cache"] }

Import path: helpers4::cache.

ItemWhat it does
ExpiringMapA map whose entries expire, with the clock passed in by the caller.
ExpiringSetA set whose members expire: an ExpiringMap without values.
LruCacheA map bounded to at most capacity entries: once full, inserting a new key evicts the least recently used one.