我明白多个对象,使用Spring的(3.1)建于CacheManager中使用的Ehcache实现,也有一定的局限性在代理模式下(默认设置)时,按这个帖子:的Ehcache:@CacheEvict上使用批注
Spring 3.1 @Cacheable - method still executed
来考虑一下,我有:
@CacheEvict(value = "tacos", key = "#tacoId", beforeInvocation = true)
removeTaco(String tacoId) {
// Code to remove taco
}
removeTacos(Set<String> tacoIds) {
for (String tacoId : tacoIds) {
removeTaco(tacoId);
}
}
在这个仓库方法,调用removeTacos(tacoIds)实际上并不会因为从上述限制的缓存集中退出任何东西。我的解决方法是,在上面的服务层上,如果我想要删除多个玉米饼,我会遍历每个taco Id并将其传递到removeTaco(),并且从不使用removeTacos()但是,我不会使用removeTacos()想知道是否有另一种方法来实现这一点。
1)是否有一个SpEL表达式可以传递给关键字,告诉EhCache过期Set中的每个ID?
e.g. @CacheEvict(value = "tacos", key = "#ids.?[*]") // I know this isn't valid, just can't find the expression.
或者有没有一种方法可以让removeTacos()调用removeTaco并实际过期Cached对象?