loading code fetching the highlighted snippet
Fill a bounded MemoryCache, access entries, and watch how expired entries are reclaimed before least recently used valid keys leave.
least recently used: the oldest untouched key is the first
candidate when the cache reaches capacity.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.ttl and maxSize are both configured, expired entries are
removed before any valid LRU entry is evicted.maxSize resets the demo so capacity, rank, and eviction behavior
stay easy to compare.full cache evicts the least recently used key