juniorCaching
Explain the concept of TTL (Time to Live).
Updated Apr 28, 2026
Short answer
The amount of time a cached record is considered valid before it expires and must be refreshed.
Deep explanation
Caching is essential for performance optimization. The amount of time a cached record is considered valid before it expires and must be refreshed. By reducing the need to access slower storage layers (like HDDs or remote databases), systems can achieve much lower latency.
Real-world example
Storing the results of a complex database query in Redis.
Common mistakes
- Not setting a TTL, leading to the cache growing indefinitely or serving very old data.
Follow-up questions
- Is cache persistent?