Expand description
Weighted block cache: per-entry byte size.
The base cache assumes uniform entry size and counts capacity in
slots. A weighted cache counts capacity in bytes. The caller
supplies size_of: fn(&V) -> usize (or any closure). On put, the
cache adds the entry’s size to a running total; if the total
exceeds capacity_bytes it evicts via clock-sweep (LRU-ish via
second-chance) until the total fits again. Eviction may free more
than the minimum needed for one put if the working set has many
small entries.
A single put whose value is itself larger than capacity is rejected: the cache cannot hold it, so we return the new key+value as the “evicted” pair without touching residents.