I generally use the @Cacheable
with a cache config in my spring-boot app and set specific TTL (time to live) for each cache.
I recently inherited a spring b
Spring @Cacheable does not have any configurable option to set TTL
for the cache though you can build it using @CacheEvict and @Scheduled, as follows:
@CacheEvict(allEntries = true, cacheNames = { "cache_1", "cache_2" })
@Scheduled(fixedDelay = 30000)
public void cacheEvict() {
}
You can find detailed solution/explanation here - Setting TTL for @Cacheable – Spring.