FIG-001/ EVICTION-POLICY

trace lru eviction.

Fill a bounded MemoryCache, access entries, and watch how expired entries are reclaimed before least recently used valid keys leave.

  • LRU means least recently used: the oldest untouched key is the first candidate when the cache reaches capacity.
  • Clicking an entry calls get(key), moving that key to the MRU end of the list.
  • add entry writes a new item. If size === maxSize after expired entries are pruned, the current LRU key is evicted.
  • When ttl and maxSize are both configured, expired entries are removed before any valid LRU entry is evicted.
  • Changing maxSize resets the demo so capacity, rank, and eviction behavior stay easy to compare.
↩ all examples
pattern · least recently used mode · live running source
size · 3/5
lru · item:1
mru · item:3
accesses · 0
evictions · 0
capacity 3/5

full cache evicts the least recently used key

eviction log 0
fill the cache, then add one more item
rank
key
state
policy · least recently used
capacity · 5
entries · 3
next eviction · item:1
mode · live
category · eviction-policy
sheet · sheet 01 / 01
⟳ to re-run