A cache subtracts elapsed seconds from the answer TTL.
Elapsed time is subtracted
The cache starts at TTL 300 and subtracts elapsed seconds.
start TTL=300
After elapsed time
After 120 seconds, remaining TTL is 180.
300−120=180
A positive remainder is valid
Because the remaining TTL is still above zero, the toy cache can still use the answer.
remaining=180
Summary
Remaining TTL is starting TTL minus elapsed seconds, clamped at zero.
remaining=180