使用Spring缓存时如何获取cacheKey?

时间:2018-11-12 09:50:29

标签: spring spring-cache

使用Spring缓存时如何获取cacheKey?例如,以下代码,该函数(getCacheKey())应如何实现?

@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 个答案:

答案 0 :(得分:0)

String key = cachePut.key()当您从method获得注释时,它是一个包含注释属性的实例