What I am trying to do is to have an Annotation which looks a lot like the @Cacheable Annotation Spring is providing.
Used on top of a method it looks like the following:
@CleverCache(key = "'orders_'.concat(#id)")
public Order getOrder(int id) {
When I use the same using Cacheable it is somehow able to interpret this SpEL-Expression and generate a key which has the value orders_1234 (for id=1234)
My matching advice looks like the following:
@Around("CleverCachePointcut(cleverCache)")
public Object clevercache(ProceedingJoinPoint joinPoint, CleverCache cleverCache) throws Throwable {
String expression = cleverCache.key();
//FIXME: Please add working code here :D - extracting the key by interpreting the passed SpEL Expression in expression
I definitly get the expression there, but I didn't yet figure out how to make it work that it is correctly interpreting the SpEL-Expression.
Another support syntax should be key = "T(com.example.Utils).createCacheKey(#paramOfMethodByName)" where the a static helper for creating a key is invoked.
Any idea how this could work? The code where I have the snippets from is available at: https://github.com/eiselems/spring-redis-two-layer-cache/blob/master/src/main/java/com/marcuseisele/example/twolayercache/clevercache/ExampleAspect.java#L35
Any help is really appreciated!
