private boolean hasCachePut(CacheOperationContexts contexts) { // Evaluate the conditions *without* the result object because we don't have it yet... Collection<CacheOperationContext> cachePutContexts = contexts.get(CachePutOperation.class); Collection<CacheOperationContext> excluded = new ArrayList<>(); for (CacheOperationContext context : cachePutContexts) { try { if (!context.isConditionPassing(CacheOperationExpressionEvaluator.RESULT_UNAVAILABLE)) { excluded.add(context); } } catch (VariableNotAvailableException ex) { // Ignoring failure due to missing result, consider the cache put has to proceed } } // Check if all puts have been excluded by condition return (cachePutContexts.size() != excluded.size()); }
private boolean hasCachePut(CacheOperationContexts contexts) { // Evaluate the conditions *without* the result object because we don't have it yet... Collection<CacheOperationContext> cachePutContexts = contexts.get(CachePutOperation.class); Collection<CacheOperationContext> excluded = new ArrayList<>(); for (CacheOperationContext context : cachePutContexts) { try { if (!context.isConditionPassing(CacheOperationExpressionEvaluator.RESULT_UNAVAILABLE)) { excluded.add(context); } } catch (VariableNotAvailableException ex) { // Ignoring failure due to missing result, consider the cache put has to proceed } } // Check if all puts have been excluded by condition return (cachePutContexts.size() != excluded.size()); }
CacheOperationContext context = contexts.get(CacheableOperation.class).iterator().next(); if (isConditionPassing(context, CacheOperationExpressionEvaluator.NO_RESULT)) { Object key = generateKey(context, CacheOperationExpressionEvaluator.NO_RESULT); processCacheEvicts(contexts.get(CacheEvictOperation.class), true, CacheOperationExpressionEvaluator.NO_RESULT); Cache.ValueWrapper cacheHit = findCachedItem(contexts.get(CacheableOperation.class)); collectPutRequests(contexts.get(CacheableOperation.class), CacheOperationExpressionEvaluator.NO_RESULT, cachePutRequests); collectPutRequests(contexts.get(CachePutOperation.class), cacheValue, cachePutRequests); processCacheEvicts(contexts.get(CacheEvictOperation.class), false, cacheValue);
CacheOperationContext context = contexts.get(CacheableOperation.class).iterator().next(); if (isConditionPassing(context, CacheOperationExpressionEvaluator.NO_RESULT)) { Object key = generateKey(context, CacheOperationExpressionEvaluator.NO_RESULT); Cache cache = context.getCaches().iterator().next(); try { return wrapCacheValue(method, cache.get(key, () -> unwrapReturnValue(invokeOperation(invoker)))); processCacheEvicts(contexts.get(CacheEvictOperation.class), true, CacheOperationExpressionEvaluator.NO_RESULT); Cache.ValueWrapper cacheHit = findCachedItem(contexts.get(CacheableOperation.class)); collectPutRequests(contexts.get(CacheableOperation.class), CacheOperationExpressionEvaluator.NO_RESULT, cachePutRequests); collectPutRequests(contexts.get(CachePutOperation.class), cacheValue, cachePutRequests); processCacheEvicts(contexts.get(CacheEvictOperation.class), false, cacheValue);
CacheOperationContext context = contexts.get(CacheableOperation.class).iterator().next(); if (isConditionPassing(context, CacheOperationExpressionEvaluator.NO_RESULT)) { Object key = generateKey(context, CacheOperationExpressionEvaluator.NO_RESULT); processCacheEvicts(contexts.get(CacheEvictOperation.class), true, CacheOperationExpressionEvaluator.NO_RESULT); Cache.ValueWrapper cacheHit = findCachedItem(contexts.get(CacheableOperation.class)); collectPutRequests(contexts.get(CacheableOperation.class), CacheOperationExpressionEvaluator.NO_RESULT, cachePutRequests); collectPutRequests(contexts.get(CachePutOperation.class), cacheValue, cachePutRequests); processCacheEvicts(contexts.get(CacheEvictOperation.class), false, cacheValue);