1
我使用Spring 3.2缓存抽象使用ehcache作为实现。Ehcache:从缓存中删除条目存储为列表
我能够缓存返回对象列表的方法的输出,如下所示。
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(value = "empCache", key="#empId")
public void deleteEmployee(int empId) {
//deletes employee object
}