2
It is possible to schedule that the Spring cache is always redone at midnight?
I read the Springs Cache Docs and I found nothing about how to get him to be regenerated.
2
It is possible to schedule that the Spring cache is always redone at midnight?
I read the Springs Cache Docs and I found nothing about how to get him to be regenerated.
3
Something that could be done is to use cache expiration (@CacheEvict
) together with the scheduling (Scheduled
), as below:
@Configuration
@EnableCaching
@EnableScheduling
public class CachingConfig {
public static final String GAMES = "GAMES";
@Bean
public CacheManager cacheManager() {
ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager(GAMES);
return cacheManager;
}
@CacheEvict(allEntries = true, value = {GAMES})
@Scheduled(cron = "* * 0 * * ?")
public void reportCacheEvict() {
System.out.println("Flush Cache " + dateFormat.format(new Date()));
}
}
Based in this answer.
Browser other questions tagged java java-ee spring
You are not signed in. Login or sign up in order to post.
I think you are looking for this [https://spring.io/guides/gs/scheduling-tasks/]
– Erick Maia
Has the answer helped you to resolve the doubt? It is possible to accept it now?
– Murillo Goulart
Good afternoon, @Murilo, there have been other priorities over the past few weeks and the past. I’m coming back to this solution now and I’m already responding.
– Philippe Gioseffi