作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试逐出 Spring 管理的缓存中的条目(Spring 3.1 抽象)。
我需要在注解中引用“key”属性的SpEL中方法的返回值:
/* (How to refer to the 'T' returned value in the "KEY_ID"?) */
@Caching(evict = { @CacheEvict(value = CACHE_BY_ID, key = KEY_ID) })
public T delete(AppID appID, UserID userID) throws UserNotFoundException {
return inner.delete(appID, userID);
}
有什么办法吗?
最佳答案
似乎没有任何方法可以引用返回的对象:
但是为什么你需要这样做呢?您可以引用@CacheEvict "key"值中的参数,例如:
@CacheEvict(value = CACHE_BY_ID, key = "#userID")
public T delete(AppID appID, UserID userID) throws UserNotFoundException {
...
}
响应以下有关必须使用用户对象的多个属性从多个缓存中逐出的响应的更多示例代码:
@Caching(evict = {
@CacheEvict(value = CACHE_BY_ID, key = "#user.userID"),
@CacheEvict(value = CACHE_BY_LOGIN_NAME, key = "#user.loginName")
// etc.
})
public T delete(AppID appID, User user) throws UserNotFoundException {
...
}
关于java - Spring 3.1缓存——如何在SpEL中使用返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10678524/
我是一名优秀的程序员,十分优秀!