我正在使用使用 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
}
但是我无法List<Employee>
使用下面给出的代码通过@CacheEvict 在更新或删除时从缓存中存储的对象中删除特定条目
@CacheEvict(value = "empCache", key="#empId")
public void deleteEmployee(int empId) {
//deletes employee object
}