LruStateCache
class LruStateCache(capacity: Int = Int.MAX_VALUE, maxBytes: Long = Long.MAX_VALUE, weigh: (CachedState) -> Long = CachedState::bytes, evicted: () -> Unit = {}) : StateCache
A StateCache of at most capacity aggregates and maxBytes of their estimated size (weigh), evicting the least recently used while either is passed. Taking a state out (for a command) frees its room until the command puts it back, weighed again then. invalidate drops a partition's states when the node acquires or releases it, scanning every stripe; dropBefore drops one state behind the log, under its stripe's lock.
A large cache is striped by aggregate: each of up to Stripes.MAX stripes is an LRU of its share of the bounds under its own lock, so the commands of different aggregates rarely take the same lock. Eviction is then least recently used within a stripe; a cache smaller than two stripes' minimum is one exact LRU.
Constructors
Link copied to clipboard
constructor(capacity: Int = Int.MAX_VALUE, maxBytes: Long = Long.MAX_VALUE, weigh: (CachedState) -> Long = CachedState::bytes, evicted: () -> Unit = {})