liveBook · Manning

Expiration date

As explained in Latency

Time-to-live is a caching mechanism that limits how long an entry remains valid before it is treated as expired and removed or refreshed.

An expiration date, or time-to-live (TTL), limits how long a cached entry remains valid. After that period, the entry is considered stale and must be removed, refreshed, or retrieved again from the backing store. section 6.7 section 6.11

TTL provides a simple freshness boundary, but its setting creates practical trade-offs:

  • Choose the duration in units such as seconds, minutes, hours, or days according to the data’s update rate and freshness requirements. section 6.7
  • Use a shorter TTL to expose backing-store changes sooner, accepting more retrievals and potentially a lower cache hit ratio. section 6.11 section 6.7
  • Use a longer TTL to retain more cache hits, accepting a greater chance that applications read stale data. section 6.11
  • Track each entry’s insertion time and TTL, then compare the expiration time with the current time during lookup or periodic checks. section 6.7

DNS records

DNS caches domain-name-to-IP-address mappings. A stable mapping may use a TTL of 24 hours or more, while a dynamic record used for load balancing may use about 30 seconds so configuration changes become visible quickly. section 6.7

TTL addresses freshness rather than capacity. Replacement policies such as LRU, LFU, and FIFO evict entries when space is needed; TTL can expire an entry even when the cache has room. section 6.7 section 6.11

How Latency covers it

How deep it goes
Explains TTL definition, units, trade-offs, DNS choices, and expiration checks, but does not specify a cache product implementation.
Examples
Uses DNS mappings, stable IP addresses, dynamic load-balancing records, and database-backed cache entries.
What it assumes
Assumes basic caching concepts and distinguishes freshness expiration from capacity-driven cache eviction.
What you can do after
Operate/configure TTL by selecting a freshness interval and implementing expiration checks before serving cached data.
How it connects
Connects TTL with caching, cache replacement policies, cache coherency, backing stores, and write-through or write-behind caching.

Also explained in

Compare how 4 books explain expiration date →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Latency. The section links point to the parts of the book it draws on.