【发布时间】:2019-10-20 20:40:23
【问题描述】:
我正在使用 Spring Boot,而对于缓存,我正在使用 Ehcache。到目前为止它工作正常。但是现在我必须重新加载/刷新,所以我该怎么做才能让我的应用程序不会有任何停机时间。
我在 Spring Ehcache 中尝试了很多方法,但都不起作用,否则必须编写调度程序并重新加载数据。
@Override
@Cacheable(value="partTypeCache", key="#partKey")
public List<PartType> loadPartType(String partKey) throws CustomException {
return productIdentityDao.loadPartType();
}
【问题讨论】:
-
是 CacheEvict 你在找什么? :docs.spring.io/spring/docs/current/spring-framework-reference/…
-
@ItFreak CacheEvict 用于删除/清除缓存,但在我的情况下,我必须重新加载/刷新缓存,以便它与任何数据库同步。
-
我不认为有一个开箱即用的解决方案,因为这意味着框架知道所有底层数据源。
-
CacheEvict 将从缓存中删除值。我想在固定时间间隔后重新加载孔缓存而不会出现问题
标签: java spring-boot caching memcached ehcache