fal*_*con 1 java spring ehcache spring-cache
我正在使用 ehcache 缓存方法结果。键必须是成员对象和方法参数的组合。我的课程看起来像:
Class A {
private B b;
@Cacheable(value="someCache",key="some key based on B and C")
public Result getResult(C c){
......
}
Run Code Online (Sandbox Code Playgroud)
我需要基于 B 和 C 的密钥。我提到了https://code.google.com/p/ehcache-spring-annotations/issues/detail?id=69但他们没有指定如何包含方法参数在密钥生成中。有人可以帮我解决这个问题吗?
您可以使用密钥访问该A对象root.target。例如
key="#root.target.b.id+'-'+#c.id"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5845 次 |
| 最近记录: |