@Test public void testMissingKey() { final LocalAsyncCache<String, String> cache = createCache(); final ComposableFuture<String> missingValue = cache.getAsync(MISSING_KEY); assertComposableFutureError(ERROR_MESSAGE,RuntimeException.class,missingValue); }
@Override public ComposableFuture<V> getAsync(final K key) { try { if (loadingCache != null) { final ComposableFuture<V> res = loadingCache.get(key); if (res == null) { return fromNull(); } return res.recoverWith(error -> { loadingCache.asMap().remove(key, res); return fromError(error); }); } else { final ComposableFuture<V> res = localCache.getIfPresent(key); if (res == null) { return fromNull(); } return res; } } catch (final com.google.common.util.concurrent.UncheckedExecutionException e) { return fromError(e.getCause()); } catch (final ExecutionException | UncheckedExecutionException | ExecutionError e) { return fromError(e.getCause()); } }
LocalAsyncCache implements TypedCache<K,V> { @Override public ComposableFuture<V> getAsync(final K key) { try { if (loadingCache != null) { final ComposableFuture<V> res = loadingCache.get(key); if (res == null) { return fromNull(); } return res.recoverWith(error -> { loadingCache.asMap().remove(key, res); return fromError(error); }); } else { final ComposableFuture<V> res = localCache.getIfPresent(key); if (res == null) { return fromNull(); } return res; } } catch (final com.google.common.util.concurrent.UncheckedExecutionException e) { return fromError(e.getCause()); } catch (final ExecutionException | UncheckedExecutionException | ExecutionError e) { return fromError(e.getCause()); } } }
LocalAsyncCache implements TypedCache<K,V> { @Override public ComposableFuture<V> getAsync(final K key) { try { if (loadingCache != null) { final ComposableFuture<V> res = loadingCache.get(key); if (res == null) { return fromNull(); } return res.recoverWith(error -> { loadingCache.asMap().remove(key, res); return fromError(error); }); } else { final ComposableFuture<V> res = localCache.getIfPresent(key); if (res == null) { return fromNull(); } return res; } } catch (final com.google.common.util.concurrent.UncheckedExecutionException e) { return fromError(e.getCause()); } catch (final ExecutionException | UncheckedExecutionException | ExecutionError e) { return fromError(e.getCause()); } } LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit, final CacheLoader<K, V> loader,
                         final MetricFactory metricFactory, final String cacheName);  LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit, final CacheLoader<K, V> loader,
                         final MetricFactory metricFactory, final String cacheName, final boolean failOnMissingEntries);  LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit, final CacheLoader<K, V> loader);  LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit, final MetricFactory metricFactory, final String cacheName);  LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit);  LocalAsyncCache(); }
LocalAsyncCache implements TypedCache<K,V> { @Override public ComposableFuture<V> getAsync(final K key) { try { if (loadingCache != null) { final ComposableFuture<V> res = loadingCache.get(key); if (res == null) { return fromNull(); } return res.recoverWith(error -> { loadingCache.asMap().remove(key, res); return fromError(error); }); } else { final ComposableFuture<V> res = localCache.getIfPresent(key); if (res == null) { return fromNull(); } return res; } } catch (final com.google.common.util.concurrent.UncheckedExecutionException e) { return fromError(e.getCause()); } catch (final ExecutionException | UncheckedExecutionException | ExecutionError e) { return fromError(e.getCause()); } } LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit, final CacheLoader<K, V> loader,
                         final MetricFactory metricFactory, final String cacheName);  LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit, final CacheLoader<K, V> loader,
                         final MetricFactory metricFactory, final String cacheName, final boolean failOnMissingEntries);  LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit, final CacheLoader<K, V> loader);  LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit, final MetricFactory metricFactory, final String cacheName);  LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit);  LocalAsyncCache(); @Override ComposableFuture<V> getAsync(final K key); @Override ComposableFuture<Map<K, V>> getBulkAsync(final Iterable<? extends K> keys); @Override ComposableFuture<Boolean> deleteAsync(final K key); @Override ComposableFuture<Boolean> setAsync(final K key, final V value); @Override ComposableFuture<Boolean> setIfAbsentAsync(final K key, final V value); @Override ComposableFuture<Boolean> setAsync(final K key, final EntryMapper<K, V> mapper, final int maxIterations); @Override ComposableFuture<Map<K, Boolean>> setBulkAsync(final Map<? extends K, ? extends V> entries); }
LocalAsyncCache implements TypedCache<K,V> { @Override public ComposableFuture<V> getAsync(final K key) { try { if (loadingCache != null) { final ComposableFuture<V> res = loadingCache.get(key); if (res == null) { return fromNull(); } return res.recoverWith(error -> { loadingCache.asMap().remove(key, res); return fromError(error); }); } else { final ComposableFuture<V> res = localCache.getIfPresent(key); if (res == null) { return fromNull(); } return res; } } catch (final com.google.common.util.concurrent.UncheckedExecutionException e) { return fromError(e.getCause()); } catch (final ExecutionException | UncheckedExecutionException | ExecutionError e) { return fromError(e.getCause()); } } LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit, final CacheLoader<K, V> loader,
                         final MetricFactory metricFactory, final String cacheName);  LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit, final CacheLoader<K, V> loader,
                         final MetricFactory metricFactory, final String cacheName, final boolean failOnMissingEntries);  LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit, final CacheLoader<K, V> loader);  LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit, final MetricFactory metricFactory, final String cacheName);  LocalAsyncCache(final int maximumSize, final int ttl, final TimeUnit unit);  LocalAsyncCache(); @Override ComposableFuture<V> getAsync(final K key); @Override ComposableFuture<Map<K, V>> getBulkAsync(final Iterable<? extends K> keys); @Override ComposableFuture<Boolean> deleteAsync(final K key); @Override ComposableFuture<Boolean> setAsync(final K key, final V value); @Override ComposableFuture<Boolean> setIfAbsentAsync(final K key, final V value); @Override ComposableFuture<Boolean> setAsync(final K key, final EntryMapper<K, V> mapper, final int maxIterations); @Override ComposableFuture<Map<K, Boolean>> setBulkAsync(final Map<? extends K, ? extends V> entries);  }