Spring @cacheable how to refresh cache 12am?

karfai :

I would like to refresh the cache everyday 12am or the cache expired at 12am. I had check the available methods in net.sf.ehcache.config.CacheConfiguration, but these methods i.e. timeToIdleSeconds, timeToLiveSeconds seem like not what I want. May I know how to achieve this?

Edit 1:

Here is how I use @Cacheable.

@Override
@Cacheable(value = "cacheName")
public Object retrieveConfigurations() {
    ...
}
Dmitry Bogdanovich :

You can use @Scheduled:

@Scheduled(cron = "<cron expression>")
@CacheEvict(value = "<cache name>")
public void clearCache() {      
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=156766&siteId=1