java - ehcache expire ttl 不工作-springboot
问题描述
我尝试每 5 分钟刷新一次缓存。这是我的配置:
ehcache.xml:
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns='http://www.ehcache.org/v3'>
<cache alias="listOfCustomer">
<value-type>com.model.Customer</value-type>
<expiry>
<ttl unit="minutes">5</ttl>
</expiry>
<resources>
<heap unit="kB">500</heap>
</resources>
</cache>
在 application.yml spring cache 中添加了这个 xml:jcache: config: classpath:ehcache.xml
在 pom.xml 中:
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
</dependency>
课程:
@EnableCaching
@SpringBootApplication(scanBasePackages = {"com.model"})
public class DemoApp{
......
}
@Service
class GetCustomerDetails{
@Cacheable("list")
public Customer getCustomerInfo(){
......
}
}
解决方案
推荐阅读
- android - Android Studio中无用滚动条的GridView问题
- javascript - 我可以在 app.get 中使用不同路径的 app.use
- redis - 如果您不小心写入从服务器,Redis Sentinel 的预期行为是什么
- php - 创建 json 数组时,如果文本有特殊字符,则不显示任何内容
- r - 如何从 uGARCHfit(rugarch 包)中提取 AIC
- html - 垂直对齐不是像素完美的
- c++ - 可以将 GCC 配置为忽略 #pragma 指令吗?
- javascript - 打印任何 javascript 对象
- c++ - 使用 SDL_mixer 播放 .ogg 文件时出现问题
- python - 如何打印带有对齐文本的列表列表,rjust() 的整数长度来自列表中字符串的最大长度。