2 · REDIS · TTL ▶ Run: P5 TTL is not a guarantee of freshness Lifespan Human Chain: Predict the TTL SET session:9f3a 1042 EX 1800 TTL session:9f3a -> ≈1800 TTL leaderboard:season:7 -> -1 no time limit TTL nosuchkey -> -2 key does not exist GET and HGET do not extend the TTL SET k v1 EX 300 TTL k -> ≈300 SET k v2 TTL k -> -1 SET k v3 KEEPTTL TTL k -> -1 (!) EXPIRE k 300 SET k v4 KEEPTTL TTL k -> ≈300 k = lesson03:ttl:lecture SET turns off TTL HSET and TTL fields Cache-aside A normal rewrite resets the TTL. KEEPTTL preserves the existing TTL but does not restore a reset TTL. The key's expiration time is preserved, and the TTL of the overwritten field is reset. HEXPIRE — available in Redis 7.4. Miss → source → cache with TTL; after commit — DEL. Race condition: an old read will overwrite the cache after the DEL. DEL + TTL do not exclude stale responses. Specify the acceptable lag and race policy; for strict requirements, specify versions or reading from the source. Run — P5. ▶ P13: Avalanche