how can i get cacheKey when use spring cache?

Viewed 62

how can i get cacheKey when use spring cache? For example, the following code , How should this function( getCacheKey()) be implemented?

@Around("@annotation(org.springframework.cache.annotation.CachePut)")
public Object processCachePut(ProceedingJoinPoint point) throws Throwable {
    Method realMethod = getRealMethod(point);
    Object result = point.proceed();
        String notice = null;
        if (realMethod.isAnnotationPresent(CachePut.class)) {
            CachePut cachePut = realMethod.getDeclaredAnnotation(CachePut.class);

            String key = getCacheKey();
        }
    return result;
}
1 Answers

String key = cachePut.key() when you got a annotation from method , it's a instance contains annotation's property

Related