【发布时间】:2020-04-13 22:08:33
【问题描述】:
如果我直接致电@Cacheable (findById),它运行良好。但是如果我从@Cacheput 方法调用,那就不行了。
@Cacheable(key = "#p0")
public User findById(String userId) {
User user = userRepository.findById(userId).orElseThrow(() -> new NotFoundException());
return user;
}
@CachePut(key = "#p0")
public User disabled(String userId) {
User user = findById(userId);
user.setStatus(0);
userRepository.save(user);
return user;
}
【问题讨论】: