I have a very small table which is not updated frequently. I want to add this to cache such that it updates every day. I am using spring and caffeine to implement this. I able to load a startup but don't how to refresh it. Please help.
@Bean
public CacheManager cacheManager() {
SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
Cache stringStringCache = new CaffeineCache("name", Caffeine.newBuilder()
.recordStats()
.maximumSize(100)
.expireAfterWrite(1, TimeUnit.DAYS)
.build());
simpleCacheManager.setCaches(Collections.singleton(stringStringCache));
return simpleCacheManager;
}
I can simply fetch all records from repository and put that in the cache using cache.put(). But how i refresh it again from table after specified time interval.