@Override public boolean containsKey(final K key) throws StoreAccessException { try { return getInternal(key) != null; } catch (TimeoutException e) { return false; } }
/** * The assumption is that this method will be invoked only by cache.getAll method. */ @Override public Map<K, ValueHolder<V>> bulkComputeIfAbsent(final Set<? extends K> keys, final Function<Iterable<? extends K>, Iterable<? extends Map.Entry<? extends K, ? extends V>>> mappingFunction) throws StoreAccessException { if(mappingFunction instanceof Ehcache.GetAllFunction) { Map<K, ValueHolder<V>> map = new HashMap<>(); for (K key : keys) { ValueHolder<V> value; try { value = getInternal(key); } catch (TimeoutException e) { // This timeout handling is safe **only** in the context of a get/read operation! value = null; } map.put(key, value); } return map; } else { throw new UnsupportedOperationException("This bulkComputeIfAbsent method is not yet capable of handling generic computation functions"); } }
@Override public ValueHolder<V> getAndFault(K key) throws StoreAccessException { getAndFaultObserver.begin(); ValueHolder<V> value; try { value = getInternal(key); } catch (TimeoutException e) { getAndFaultObserver.end(AuthoritativeTierOperationOutcomes.GetAndFaultOutcome.TIMEOUT); return null; } if(value == null) { getAndFaultObserver.end(AuthoritativeTierOperationOutcomes.GetAndFaultOutcome.MISS); return null; } else { getAndFaultObserver.end(AuthoritativeTierOperationOutcomes.GetAndFaultOutcome.HIT); return value; } }
@Override public ValueHolder<V> get(final K key) throws StoreAccessException { getObserver.begin(); ValueHolder<V> value; try { value = getInternal(key); } catch (TimeoutException e) { getObserver.end(StoreOperationOutcomes.GetOutcome.TIMEOUT); return null; } if(value == null) { getObserver.end(StoreOperationOutcomes.GetOutcome.MISS); return null; } else { getObserver.end(StoreOperationOutcomes.GetOutcome.HIT); return value; } }
@Override protected ValueHolder<V> getInternal(K key) throws StoreAccessException, TimeoutException { ValueHolder<V> holder = super.getInternal(key); try { if (holder == null) {
@Override public boolean containsKey(final K key) throws StoreAccessException { try { return getInternal(key) != null; } catch (TimeoutException e) { return false; } }
/** * The assumption is that this method will be invoked only by cache.getAll method. */ @Override public Map<K, ValueHolder<V>> bulkComputeIfAbsent(final Set<? extends K> keys, final Function<Iterable<? extends K>, Iterable<? extends Map.Entry<? extends K, ? extends V>>> mappingFunction) throws StoreAccessException { if(mappingFunction instanceof Ehcache.GetAllFunction) { Map<K, ValueHolder<V>> map = new HashMap<>(); for (K key : keys) { ValueHolder<V> value; try { value = getInternal(key); } catch (TimeoutException e) { // This timeout handling is safe **only** in the context of a get/read operation! value = null; } map.put(key, value); } return map; } else { throw new UnsupportedOperationException("This compute method is not yet capable of handling generic computation functions"); } }
@Override public ValueHolder<V> get(final K key) throws StoreAccessException { getObserver.begin(); ValueHolder<V> value; try { value = getInternal(key); } catch (TimeoutException e) { getObserver.end(StoreOperationOutcomes.GetOutcome.TIMEOUT); return null; } if(value == null) { getObserver.end(StoreOperationOutcomes.GetOutcome.MISS); return null; } else { getObserver.end(StoreOperationOutcomes.GetOutcome.HIT); return value; } }
@Override public ValueHolder<V> getAndFault(K key) throws StoreAccessException { getAndFaultObserver.begin(); ValueHolder<V> value; try { value = getInternal(key); } catch (TimeoutException e) { getAndFaultObserver.end(AuthoritativeTierOperationOutcomes.GetAndFaultOutcome.TIMEOUT); return null; } if(value == null) { getAndFaultObserver.end(AuthoritativeTierOperationOutcomes.GetAndFaultOutcome.MISS); return null; } else { getAndFaultObserver.end(AuthoritativeTierOperationOutcomes.GetAndFaultOutcome.HIT); return value; } }