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
With spring boot, I was able to achieve success with this:
First, you need to add spring-boot-starter-data-redis
artifact to your POM file.
org.springframework.boot
spring-boot-starter-data-redis
After this, you need to add the required the following configurations in your application.properties files:
#------ Redis Properties -------------
spring.cache.type=redis
spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.cache.redis.time-to-live=600000
The property to set is spring.cache.redis.time-to-live
(value is in milliseconds. 10 mins was set in this case). With this, @Cacheable
works with the set default TTL.