@Override public void clear() { this.cache.removeAll(); }
@Override public void clear() { this.cache.removeAll(); }
@Override public void remove(final Function<K, Boolean> keyMatcher) { final Set<K> toRemove = new HashSet<K>(); for (final Object key : getKeys()) { if (keyMatcher.apply((K) key) == Boolean.TRUE) { toRemove.add((K) key); } } cache.removeAll(toRemove); }
@Test public void removeAll() { cache.put(1, "a"); cache.put(2, "b"); changesOf(0, 0, 2, 0); cache.removeAll(); changesOf(0, 0, 0, 2); }
@Test public void removeAllKeys() { cache.put(1, "a"); cache.put(2, "b"); changesOf(0, 0, 2, 0); cache.removeAll(asSet(1, 2, 3)); changesOf(0, 0, 0, 2); }
private void innerClear() { cache.get(1); // one miss cache.getAll(asSet(1, 2, 3)); // 3 misses cache.put(1, "a"); // one put cache.put(1, "b"); // one put and update cache.putAll(Collections.singletonMap(2, "b")); // 1 put cache.get(1); // one hit cache.remove(1); // one remove cache.removeAll(); // one remove changesOf(1, 4, 3, 2); cacheStatistics.clear(); changesOf(-1, -4, -3, -2); } }
@Override public void removeAll() { cache.removeAll(); }
/** * Remove everything in the cache. */ public void clear() { Cache<K, V> cache = getOpenIDCache(); if (cache != null) { cache.removeAll(); } }
void clear() { if (simpleCache != null) { simpleCache = new SimpleCache<>(simpleCache.maxEntries); } else if (isCarbonCache) { Cache<IdentityCacheKey, IdentityCacheEntry> carbonCache = getCommonCache(); if (carbonCache != null) { carbonCache.removeAll(); } } }
/** {@inheritDoc} */ @Override public void clear() { getCacheManager().getPropertiesCache().removeAll(); }
/** {@inheritDoc} */ @Override public void clear() { getCacheManager().getFeaturesCache().removeAll(); }
@Override public void updateAllPolicies(List<Policy> policies) { Cache<Integer, List<Policy>> lCache = getPolicyListCache(); lCache.removeAll(); lCache.put(1, policies); }
void clear() { if (simpleCache != null) { simpleCache = new SimpleCache<>(simpleCache.maxEntries); } else if (isCarbonCache) { Cache<IdentityCacheKey, IdentityCacheEntry> carbonCache = getCommonCache(); if (carbonCache != null) { carbonCache.removeAll(); } } }
/** * Remove everything in the cache. */ public void clear() { if (!isEnabled()) { return; } Cache<K, V> cache = getBaseCache(); if (cache != null) { cache.removeAll(); } }
@Test public void removeAll_1arg_NullKey() { HashSet<Long> keys = new HashSet<Long>(); keys.add(null); try { cache.removeAll(keys); fail("should have thrown an exception - null key not allowed"); } catch (NullPointerException e) { //expected } }
private void removeAll(final CacheKeyInvocationContext<CacheRemoveAll> context, final CacheDefaults defaults, final CacheRemoveAll cacheRemoveAll) { final Cache<Object, Object> cache = helper.cacheResolverFactoryFor(defaults, cacheRemoveAll.cacheResolverFactory()).getCacheResolver(context).resolveCache(context); cache.removeAll(); } }
@Test public void removeAll_1arg_Null() { try { cache.removeAll(null); fail("should have thrown an exception - null keys not allowed"); } catch (NullPointerException e) { //good } }
@Test public void removeAll_1arg_Closed() { cache.close(); try { cache.removeAll(null); fail("should have thrown an exception - cache closed"); } catch (IllegalStateException e) { //good } }