安排Spring缓存逐出? [英] Schedule Spring cache eviction?

查看:84
本文介绍了安排Spring缓存逐出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将春季快取驱逐活动安排到午夜的每一天?

Is it possible to schedule spring cache eviction to everyday at midnight?

我已阅读 Springs Cache Docs ,但对计划的缓存逐出一无所获.

I've read Springs Cache Docs and found nothing about scheduled cache eviction.

我需要逐出缓存并重新缓存,以防应用程序外部发生某些变化.

I need to evict cache daily and recache it in case there were some changes outside my application.

推荐答案

尝试使用@Scheduled 示例:

Try to use @Scheduled Example:

@Scheduled(fixedRate = ONE_DAY)
@CacheEvict(value = { CACHE_NAME })
public void clearCache() {      
}

您还可以将cron表达式与@Scheduled一起使用.

You can also use cron expression with @Scheduled.

这篇关于安排Spring缓存逐出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆