我有两种这样的方法:
首先,我要让用户存款
@Override
@Transactional
@Cacheable(value = "deposits")
public Set<Deposit> getUserDeposit() {
User user = userRepository.findOneByUsername(
securityHolder.getUserDetails().getUsername());
Set<Deposit> deposits = user.getBalance().getDeposits();
return deposits;
}
其次,当保存包含一个存款作为关系的任务实体时,我希望通过 id 从缓存存款中逐出:
(弹簧数据接口)
@CacheEvict(value = "deposits", key = "#entity.deposit.id", condition = "#entity != null")
<S extends T> List<S> save(Iterable<S> entity);
但那没有用。