logo memory /cache v1.1.2
FIG-001/ WEIGHTED-LRU

bound aggregate weight.

Cache API-response-like records with logical KiB weights, protect entries through access, and trigger single or multiple LRU evictions from one insertion.

  • maxWeight limits aggregate application-defined weight. It does not measure retained JavaScript heap automatically.
  • This cache uses maxSize: 0 so weight is its only capacity limit; the normal default remains 100 entries.
  • Access calls cache.get(key) and moves that record to MRU. Weighted LRU removes the least recently used record, not the physically largest one.
  • Select an 8 KiB record at the default limit and add it to watch one insertion evict multiple older records until the aggregate fits.
↩ all examples
policy · weighted least recently used mode · live running source
weight · 7/8 KiB
entries · 3
lru · api:1
mru · api:3
evictions · 0
aggregate weight 7/ 8 KiB

user-defined logical payload cost, not measured heap memory

changing the limit resets the seeded cache
next response weight
onEvict log 0
select 8 KiB and add to trigger multi-eviction
rank
api response
weight / state
// seeded 1 + 2 + 4 KiB responses
policy · weighted LRU
maxSize · 0
calculator · logicalWeight
next out · api:1
mode · live
category · weighted-lru
sheet · sheet 01 / 01
⟳ to re-run