Cachingttlexpiryexpiration
TTL (time to live)
Definition
A TTL is a lifetime attached to a piece of data; once it elapses, caches treat the entry as expired and fetch a fresh copy on the next request.
In practice
TTL is the simplest freshness control: it bounds how stale data can get without any invalidation logic. Short TTLs keep data fresh but lower the hit ratio and raise backend load; long TTLs do the opposite.
If many entries share the same TTL and were filled at the same moment, they expire together and cause a stampede. Adding random jitter to TTLs spreads expirations out.
Example
A currency rate cached with a 60-second TTL is never more than one minute old, and the rates service receives at most one request per minute per cache node for it.