【发布时间】:2014-10-23 06:22:12
【问题描述】:
我正在使用使用 ehcache 作为实现的 Spring 3.2 缓存抽象。
我能够缓存返回对象列表的方法的输出,如下所示。
public Class Employee
{
private int empId;
private String name;
//getters and setters
}
@Cacheable(value = "empCache")
public List<Employee> getAllEmployess() {
//method queries the db and returns a list of all employees
}
但我无法使用下面给出的代码通过@CacheEvict 在更新或删除时从缓存中存储的List<Employee> 对象中删除特定条目
@CacheEvict(value = "empCache", key="#empId")
public void deleteEmployee(int empId) {
//deletes employee object
}
【问题讨论】:
标签: caching ehcache spring-cache