I am using RedisCacheManager using spring boot. I want to expire the cache at 23:59:59 everyday i.e end of the day. How can I do that? I can see that it can be done only relatively by using Duration.ofHours(3) Or Duration.ofMinutes(3) etc. But in my case, I want to set the ttl to a specific time, so that the cache expires every day at 23:59:59. Below is the code snippet I am using :
public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) { Duration expiration = Duration.ofHours(3); RedisCacheManager redisCacheManager = RedisCacheManager.builder(redisConnectionFactory) .cacheDefaults( RedisCacheConfiguration.defaultCacheConfig() .serializeValuesWith( RedisSerializationContext.SerializationPair.fromSerializer( new GenericJackson2JsonRedisSerializer())) .entryTtl(expiration)) .build(); redisCacheManager.setTransactionAware(false); return redisCacheManager; }
Please suggest.