The Hourglass
Caches forget on purpose.
What you're wiring up
This stage attaches deadlines to keys: SET k v PX 100 means "this key dies in 100 ms." The elegant idea: expiry needs no timer-per-key. Lazy expiration — every read first checks "is this key past its deadline?" and deletes it on the spot — is correct all by itself. A background active sweep merely keeps memory from silting up with keys nobody reads.
You'll also meet time-as-data: store the absolute deadline (time.Now().Add(d)), never the remaining duration, or every check drifts.
Assembly steps
hint
Parse SET's options after arg 2 in a loop — you're building a tiny option grammar.
hint
Plain SET (no EX/PX) on an existing key wipes the old TTL — Redis semantics; the harness checks this exact case.
hint
time.NewTicker + for range ticker.C, started at server boot. Take the write lock per sweep; scanning all keys is fine at this scale.
Go deeper (after it passes)
Pairs with HFDP M1 — Strategy (lazy vs active expiry as swappable policies) and DDIA M8 — Everything Fails (time is data).