If I am using @Cashable annotation to cache the results using a ConcurrentMapCacheManager, then how would I periodically refresh the cache in Spring 4.3.5?
It looks like Ehcache provides some implementation and it depends on the backing store, but I would like to understand in case I am not using any external cache backing store.
One option I am thinking about is to periodically call a method, but what implementation will go into that method? How will I collect and call all those cachable methods again?
It would be great to look at some examples.
There is no direct spring abstraction for periodic cache refresh, you can also verify here from spring docs, but, you can achieve the same with the simple scheduled method using @Scheduled like below:
@Scheduled(cron = "${YOUR_CRON_INTERVAL}")
@CacheEvict(value = "yourCache", allEntries = true)
public void resetAllEntries() {
//write the code to repopulate the cache again here
}