@Override public void delete(final String key) { localCache.remove(key); }
@Override public void deleteWithConfirmation(final Callback<Boolean> confirmation, final String key) { localCache.remove(key); confirmation.accept(true); }
@Override public void delete(final String key) { cache.remove(key); writeBehindWriter.delete(key); }
@Override public void getBytes(final Callback<Optional<byte[]>> callback, final String key) { final CacheEntry cacheEntry = localCache.get(key); if (cacheEntry == null) { callback.resolve(Optional.<byte[]>empty()); return; } if (cacheEntry.isExpired(time)) { localCache.remove(key); callback.resolve(Optional.<byte[]>empty()); } else { final byte[] value = ((CacheBytesEntry) cacheEntry).value; if (value == null) { callback.resolve(Optional.<byte[]>empty()); } else { callback.resolve(Optional.of(value)); } } }
@Override public void getString(final Callback<Optional<String>> callback, final String key) { final CacheEntry cacheEntry = localCache.get(key); if (cacheEntry == null) { callback.resolve(Optional.<String>empty()); return; } if (cacheEntry.isExpired(time)) { localCache.remove(key); callback.resolve(Optional.<String>empty()); } else { final String value = ((CacheStringEntry) cacheEntry).value; if (value == null) { callback.resolve(Optional.<String>empty()); } else { callback.resolve(Optional.of(value)); } } }
@Override public void deleteWithConfirmation(Callback<Boolean> confirmation, String key) { cache.remove(key); final CallbackBuilder callbackBuilder = reactor.callbackBuilder(); if (debug) { callbackBuilder.wrapWithLogging(confirmation, logger, String.format("get %s", key)); } else { callbackBuilder.wrapWithLogging(confirmation, logger, "hasKey operation"); } writeBehindWriter.deleteWithConfirmation(callbackBuilder.build(), key); }
private CacheEntry<T> doGetCacheEntry(final Callback<Optional<T>> callback, final String key) { CacheEntry<T> cacheEntry = cache.get(key); if (cacheEntry != null) { if (cacheEntry.isExpired(time)) { statsCollector.increment(statKey + "expire"); cache.remove(key); //do not return so we can look things up in the fallbackReader. return null; } else { final T value = cacheEntry.getValue(); if (value == null) { callback.resolve(Optional.<T>empty()); } else { statsCollector.increment(statKey + "cacheHit"); callback.resolve(Optional.of(value)); } } } return cacheEntry; }
@Override public void hasKey(final Callback<Boolean> hasKeyCallback, final String key) { final CacheEntry cacheEntry = localCache.getSilent(key); if (cacheEntry == null) { hasKeyCallback.resolve(false); } else { if (cacheEntry.isExpired(time)) { localCache.remove(key); hasKeyCallback.resolve(false); } else { final Object value = cacheEntry.getValue(); if (value == null) { hasKeyCallback.resolve(false); } else { hasKeyCallback.resolve(true); } } } }
@Override public void delete(final String key) { localCache.remove(key); }
@Override public void delete(final String key) { localCache.remove(key); }
@Override public void hasKey(final Callback<Boolean> hasKeyCallback, final String key) { final CacheEntry<T> cacheEntry = cache.getSilent(key); if (cacheEntry != null) { if (cacheEntry.isExpired(time)) { statsCollector.increment(statKey + "expire"); cache.remove(key); //do not return so we can look things up in the fallbackReader. } else { final T value = cacheEntry.getValue(); if (value == null) { hasKeyCallback.resolve(false); } else { hasKeyCallback.resolve(true); } return; } } final CallbackBuilder callbackBuilder = reactor.callbackBuilder(); if (debug) { callbackBuilder.wrapWithLogging(hasKeyCallback, logger, String.format("get %s", key)); } else { callbackBuilder.wrapWithLogging(hasKeyCallback, logger, "hasKey operation"); } fallbackReader.hasKey(callbackBuilder.build(), key); }
@Override public void delete(final String key) { cache.remove(key); writeBehindWriter.delete(key); }
@Override public void deleteWithConfirmation(final Callback<Boolean> confirmation, final String key) { localCache.remove(key); confirmation.accept(true); }
@Override public void delete(final String key) { cache.remove(key); writeBehindWriter.delete(key); }
@Override public void deleteWithConfirmation(final Callback<Boolean> confirmation, final String key) { localCache.remove(key); confirmation.accept(true); }
@Override public void getString(final Callback<Optional<String>> callback, final String key) { final CacheEntry cacheEntry = localCache.get(key); if (cacheEntry == null) { callback.returnThis(Optional.<String>empty()); return; } if (cacheEntry.isExpired(time)) { localCache.remove(key); callback.returnThis(Optional.<String>empty()); } else { final String value = ((CacheStringEntry) cacheEntry).value; if (value == null) { callback.returnThis(Optional.<String>empty()); } else { callback.returnThis(Optional.of(value)); } } }
@Override public void deleteWithConfirmation(Callback<Boolean> confirmation, String key) { cache.remove(key); final CallbackBuilder callbackBuilder = reactor.callbackBuilder(); if (debug) { callbackBuilder.wrapWithLogging(confirmation, logger, String.format("get %s", key)); } else { callbackBuilder.wrapWithLogging(confirmation, logger, "hasKey operation"); } writeBehindWriter.deleteWithConfirmation(callbackBuilder.build(), key); }
@Override public void deleteWithConfirmation(Callback<Boolean> confirmation, String key) { cache.remove(key); final CallbackBuilder callbackBuilder = reactor.callbackBuilder(); if (debug) { callbackBuilder.wrapWithLogging(confirmation, logger, String.format("get %s", key)); } else { callbackBuilder.wrapWithLogging(confirmation, logger, "hasKey operation"); } writeBehindWriter.deleteWithConfirmation(callbackBuilder.build(), key); }
@Override public void hasKey(final Callback<Boolean> hasKeyCallback, final String key) { final CacheEntry cacheEntry = localCache.getSilent(key); if (cacheEntry == null) { hasKeyCallback.resolve(false); } else { if (cacheEntry.isExpired(time)) { localCache.remove(key); hasKeyCallback.resolve(false); } else { final Object value = cacheEntry.getValue(); if (value == null) { hasKeyCallback.resolve(false); } else { hasKeyCallback.resolve(true); } } } }
@Override public void hasKey(final Callback<Boolean> hasKeyCallback, final String key) { final CacheEntry cacheEntry = localCache.getSilent(key); if (cacheEntry == null) { hasKeyCallback.returnThis(false); } else { if (cacheEntry.isExpired(time)) { localCache.remove(key); hasKeyCallback.returnThis(false); } else { final Object value = cacheEntry.getValue(); if (value == null) { hasKeyCallback.returnThis(false); } else { hasKeyCallback.returnThis(true); } } } }