Expand description
In-memory LRU/LFU block cache with TTL-based and size-based eviction.
§Overview
BlockCache is a standalone, synchronous in-memory cache for raw block
data (identified by CID strings). It supports three eviction policies:
EvictionPolicy::LRU— evict the entry that was accessed least recently.EvictionPolicy::LFU— evict the entry that was accessed least frequently (tie-broken by last-access time so cold entries leave first).EvictionPolicy::TTL— evict expired entries first; if none are expired, fall back to LRU.
Capacity is bounded by both a maximum entry count and a maximum byte
footprint. Expired entries are lazily removed on access and can also be
swept in bulk via BlockCache::evict_expired.
Structs§
- Block
Cache - An in-memory cache for raw block data with LRU/LFU/TTL eviction and size-based capacity limits.
- Cache
Config - Configuration for a
BlockCache. - Cache
Entry - A single cached block together with its bookkeeping metadata.
- Cache
Stats - Cumulative statistics for a
BlockCache.
Enums§
- Eviction
Policy - Determines which entry is chosen for eviction when the cache is full.
Functions§
- current_
unix_ secs - Returns the current Unix time in seconds, falling back to 0 on error.