@Test public void testCacheKeyNotFound() throws Exception { Cacheable actual = cache.isCached("invalidKey"); assertThat("There should be no object cached for that key", actual, is(nullValue())); }
@Override public T isCached(final String key) { final SoftReference<CacheEntry<T>> entryRef = cache.get(key); if (isNull(entryRef)) { return null; } CacheEntry<T> entry = entryRef.get(); if (isNull(entry) || entry.expired()) { cache.remove(key, entryRef); return null; } return entry.value(); }
ConcurrentCacheMap implements Cache<T> { @Override public T isCached(final String key) { final SoftReference<CacheEntry<T>> entryRef = cache.get(key); if (isNull(entryRef)) { return null; } CacheEntry<T> entry = entryRef.get(); if (isNull(entry) || entry.expired()) { cache.remove(key, entryRef); return null; } return entry.value(); } }
ConcurrentCacheMap implements Cache<T> { @Override public T isCached(final String key) { final SoftReference<CacheEntry<T>> entryRef = cache.get(key); if (isNull(entryRef)) { return null; } CacheEntry<T> entry = entryRef.get(); if (isNull(entry) || entry.expired()) { cache.remove(key, entryRef); return null; } return entry.value(); }  }
ConcurrentCacheMap implements Cache<T> { @Override public T isCached(final String key) { final SoftReference<CacheEntry<T>> entryRef = cache.get(key); if (isNull(entryRef)) { return null; } CacheEntry<T> entry = entryRef.get(); if (isNull(entry) || entry.expired()) { cache.remove(key, entryRef); return null; } return entry.value(); }  @Override void cache(T object, long millis); @Override T isCached(final String key); }
ConcurrentCacheMap implements Cache<T> { @Override public T isCached(final String key) { final SoftReference<CacheEntry<T>> entryRef = cache.get(key); if (isNull(entryRef)) { return null; } CacheEntry<T> entry = entryRef.get(); if (isNull(entry) || entry.expired()) { cache.remove(key, entryRef); return null; } return entry.value(); }  @Override void cache(T object, long millis); @Override T isCached(final String key);  }