Allow using an instance variable in combination to arguments as key
Closed this issue · 3 comments
GoogleCodeExporter commented
Assume we have a DAO
public class DAO {
private String collection;
public DAO(Collection collection) {
this.collection = collection;
}
@Cacheable(key = @CombinedKey(
@InstanceKey("collection"),
@ArgumentKey("key")
))
public Entity find(String key) {
return // from table where key=? and collection=?
}
}
So what I wanted to illustrate with the example is that the cache key should be
the combination of the "String key" argument and instance variable "String
collection".
This would be really useful when several threads exist which each holds an DAO
instance, but initialized with different "collection" settings, thereby
logically separating them both in the database and the cache.
Original issue reported on code.google.com by johan.sj...@gmail.com
on 10 Mar 2011 at 2:35
GoogleCodeExporter commented
[deleted comment]
GoogleCodeExporter commented
This is technically possible using already with the SpELCacheKeyGenerator, e.g,
with the expression "#invocation.getThis().getCollection()".
Original comment by johan.sj...@gmail.com
on 13 Mar 2011 at 7:50
GoogleCodeExporter commented
I think the SpEL generator is your best bet here. To get this working without
SpEL would require doing reflection at runtime.
Original comment by eric.dalquist
on 19 Apr 2011 at 10:43
- Changed state: WontFix