I am using Spring 3.2 Cache abstraction using ehcache as the implementation.
I am able to cache the output of a method which returns a List of objects as illustrated below.
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
}
But i am unable to remove a particular entry from the List<Employee> object stored in the cache at times of update or delete through @CacheEvict using the code given below
@CacheEvict(value = "empCache", key="#empId")
public void deleteEmployee(int empId) {
//deletes employee object
}