// 缓存值为 null,会执行 @Cachable// 任何时候都会执行 @CachePut 和 @CacheEvictprivateObjectexecute(finalCacheOperationInvokerinvoker,Methodmethod,CacheOperationContextscontexts){if(contexts.isSynchronized()){// 默认情况下不是同步操作,这里不解析了...}// 处理注解 @CacheEvict(beforeInvocation=true)processCacheEvicts(contexts.get(CacheEvictOperation.class),true,CacheOperationExpressionEvaluator.NO_RESULT);// 从缓存中获取值Cache.ValueWrappercacheHit=findCachedItem(contexts.get(CacheableOperation.class));// Collect puts from any @Cacheable miss, if no cached item is foundList<CachePutRequest>cachePutRequests=newArrayList<>();if(cacheHit==null){// 缓存值为 null,说明要执行 @CacheablecollectPutRequests(contexts.get(CacheableOperation.class),CacheOperationExpressionEvaluator.NO_RESULT,cachePutRequests);}ObjectcacheValue;ObjectreturnValue;// 缓存值不为 null,直接使用if(cacheHit!=null&&!hasCachePut(contexts)){// If there are no put requests, just use the cache hitcacheValue=cacheHit.get();returnValue=wrapCacheValue(method,cacheValue);}else{// 调用真实方法获取值returnValue=invokeOperation(invoker);cacheValue=unwrapReturnValue(returnValue);}// Collect any explicit @CachePuts// 处理注解 @CachePutcollectPutRequests(contexts.get(CachePutOperation.class),cacheValue,cachePutRequests);// Process any collected put requests, either from @CachePut or a @Cacheable missfor(CachePutRequestcachePutRequest:cachePutRequests){cachePutRequest.apply(cacheValue);}// 处理注解 @CacheEvict(beforeInvocation=false) (默认情况)processCacheEvicts(contexts.get(CacheEvictOperation.class),false,cacheValue);returnreturnValue;}