FIG-001/ EXPIRATION-WINDOW

watch ttl countdown.

Create short-lived entries in a MemoryCache and watch each key disappear when its time-to-live window closes.

  • ttl sets the lifetime for every entry created by this cache instance.
  • The list is sorted by remainingMs, so the next key to expire stays at the top.
  • When an entry expires, MemoryCache stops returning it and the active list removes it on the next tick.
  • Changing ttl creates a fresh cache so countdowns, expiration counts, and seed data stay aligned.
↩ all examples
pattern · time to live mode · live running source
active · 3
ttl · 10s
next · temp:123
remaining · 3s
expired · 0
time to live 10s

entries disappear when their countdown reaches zero

created 3
expired 0
key
value
ttl
temp:123 1:45:57 AM
temporary data
3s
token:xyz 1:46:01 AM
auth token
7s
session:abc 1:46:04 AM
user session data
10s
policy · time to live
ttl · 10s
max size · 20
entries · 3
mode · live
category · expiration-window
sheet · sheet 01 / 01
⟳ to re-run