i have taken a look at
http://opensource.atlassian.com/confluence/spring/display/DISC/Caching+the+result+of+methods+using+Spring+and+EHCache
there is a quite simple MethodCacheInterceptor class, which uses EHCache
+ spring AOP. i think i will adapt this example to guice AOP with injection.
i think using such a method cache should really be domain specific where
i can control the input and context/semantics of the method to cache
precisely.
some reasons for that:
the cacheKey in the spring example is put together like
targetName.methodName.argument0.argument1...
i don't think that is a great idea for a general-purpose implementation
as an argument with a stupid/expensive toString method might mess
everything up.
it would make sense to aim for some kind of equals() check on the
original parameters but this will most likely kill the GC as we need to
retain the original references to the arguments.
furthermore, a general-purpose implementation would need to take into
account all current members of the class, and all static members it
accesses.
so i think i will need to roll my own specific method cache, and be
careful on what methods i apply it.
best regards
Andreas