I have spring micro-service application which using redis-server for cache store. Using RedisCacheManager Api. In this we have option to set "setDefaultExpiration". Because of that rediscachemanager calculating expiry from first access of annotated method(@cacheable).
I want to calculate expiry time from last access of cacheable method not from first access. Google library has given direct method to achive this: In CacheBuilder we have method called expireAfterAccess CacheBuilder API
We can use this when we want to use google gauva server. But in my application I have to use redis server for cache because of my centralised cache server requirement. I checked RedisCacheManager class and didn't find a way to achive this. How I can achieve this feature in redis-cache-server. Below code for creating RedisCacheManager bean:
@Bean
RedisCacheManager cacheManager() {
final RedisCacheManager redisCacheManager = new RedisCacheManager(
redisTemplate());
redisCacheManager.setUsePrefix(true);
redisCacheManager.setDefaultExpiration(redisExpireTime);
return redisCacheManager;
}