Reputation: 2365
I want to use redis as for caching my remote service request:response key :value pair using @Cacheable annotation
I know redis provides me the feature for having key specific expiry time.
Is there any provision in spring @Cacheable which allows me to use this redis feature.
Ideally , "ttl" should have been a property for @Cacheable annotation , but since not all caches support key specific ttl , spring might not have included ttl property.
As far as I have read, spring has suggested having different org.springframework.cache.CacheManager instances having different expiry time , but this seems like an overhead, given the fact that redis can already provides key specific expiry time with a single client instance.
Do you know any annotation/property/api using which I can set key specific(or method specific in case in @Cacheable) ttl when using @Cacheable annotation
Upvotes: 0
Views: 1188
Reputation: 2969
The expiration time in seconds can be set with @RedisHash(timeToLive=…)
Upvotes: 1