Spring Boot 2.1.4整合JetCache lettuce缓存框架实现本地caffeine远程redis存储
condition postcondition用法
/**
* 缓存在 Remote 的 Redis,也可以配置成 both 开启两级缓存
*/
@Cached(name = CACHE_NAME, key = "#id", cacheType = CacheType.REMOTE, serialPolicy = SerialPolicy.KRYO,
condition = "#id>0", postCondition = "result!=null")
public Coffee get(int id) {
return coffeeRepository.findById(id).orElse(null);
}
@CacheUpdate(name = CACHE_NAME, key = "#coffee.id", value = "result", condition = "#coffee.id!=null")
@Transactional
public Coffee update(Coffee coffee) {
return coffeeRepository.save(coffee);
}
版权声明:本文为fzy629442466原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。