advancedCaching with Redis

Why does a cache need an eviction/TTL strategy instead of just caching forever?

Without expiry, cached data drifts out of sync with the real database the moment the underlying row changes, serving stale data indefinitely. A TTL (`@Cacheable` with a configured Redis expiry) bounds how stale data can get, and explicit `@CacheEvict` on update/delete operations invalidates the cache immediately when you know the data changed, rather than waiting out the TTL.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to What's the core trade-off microservices make compared to a monolith?← Back to all Spring Boot questions