karfai
karfai

Reputation: 906

Spring @cacheable how to refresh cache 12am?

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() {
    ...
}

Upvotes: 3

Views: 2509

Answers (1)

Dzmitry Bahdanovich
Dzmitry Bahdanovich

Reputation: 1815

You can use @Scheduled:

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

Upvotes: 2

Related Questions