// Collect puts from any @Cachable miss
List<CachePutRequest> cachePutRequests = new ArrayList<CachePutRequest>();
collectPutRequests(contexts.get(CacheableOperation.class), ExpressionEvaluator.NO_RESULT, cachePutRequests, true);
ValueWrapper result = null;
Collection<CacheOperationContext> cacheOperationContexts = contexts.get(CacheableOperation.class);
// We only attempt to get a cached result if there are has @Cachable
if (!cacheOperationContexts.isEmpty()) {
result = findCachedResult(cacheOperationContexts);
}
// Invoke the method if don't have a cache hit
if (result == null) {
result = new SimpleValueWrapper(invoker.invoke());
}
// Collect any explicit @CachePuts
collectPutRequests(contexts.get(CachePutOperation.class), result.get(), cachePutRequests, false);
// Process any collected put requests, either from @CachePut or a @Cacheable miss
for (CachePutRequest cachePutRequest : cachePutRequests) {
cachePutRequest.apply(result.get());
}
// Process any late evictions
processCacheEvicts(contexts.get(CacheEvictOperation.class), false, result.get());
return result.get();
}