Expire at the edge
transcript
A cache entry has a lifetime. It is written at time zero. The lifetime is five.
It is alive for times zero to four. At time five it is already gone. Its age now equals its lifetime.
Test written plus lifetime against now. Strictly greater drops the entry at five. Greater or equal keeps it too long.
Entries are written at zero and three. The lifetime is five, and now is five. Only the entry from three is alive.
The wrong test returns two live entries. The right answer is one. The boundary instant caused the difference.
Ask which side of the boundary counts. Then write the comparison to match. Finally, run a boundary case yourself.
Real products expire login sessions. They expire tokens and cached pages too. An off-by-one means one extra instant of access.
Compare written plus lifetime with strictly greater. Never use greater or equal here. Then run the boundary case to be sure.
Gone means gone at the instant. Test the exact edge. Full breakdown in the lecture.