Spring @cacheable 如何在凌晨 12 点刷新缓存?

Spring @cacheable how to refresh cache 12am?

我想每天凌晨 12 点刷新缓存,或者缓存在凌晨 12 点过期。我检查了 net.sf.ehcache.config.CacheConfiguration 中可用的方法,但这些方法,即 timeToIdleSecondstimeToLiveSeconds 似乎不是我想要的。我可以知道如何实现吗?

编辑 1:

这是我使用@Cacheable 的方式。

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

您可以使用 @Scheduled:

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