You can customize your eviction time by providing an expiration card in RedisCacheManager. For example, you have a caching method specified as follows:
@Cacheable(value = "customerCache", key = "#id") public Customer findOne(Integer id) { return customerRepository.findOne(id); }
in your applicationContext.xml it will look like this:
<bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager" c:template-ref="redisTemplate" p:usePrefix="true"> <property name="expires"> <map> <entry key="customerCache" value="350"/> </map> </property> </bean>
This will allow you to configure the "customerCache" values, which will be evicted 350 seconds after they are first added to the cache.
source share