@Override public void clear() { if (_SHARED_CACHE != null) { _SHARED_CACHE.invalidateAll(); } }
@Override public void clear() { if (_SHARED_CACHE != null) { _SHARED_CACHE.invalidateAll(); } }
/** * Prunes this {@code ObjectCache}, making all its entries available for GC. */ public void invalidateAll() { sharedCache.get().invalidateAll(keyPrefix); }
/** * Prunes this {@code ObjectCache}, making all its entries available for GC. */ public void invalidateAll() { sharedCache.get().invalidateAll(keyPrefix); }
public void tearDown() { sharedCache.invalidateAll(); // CacheManager.INSTANCE.release(cache); // Preconditions.checkState(cache.sizeBytes() == 0); }
@Override public void setMaximumSize(long maxSizeBytes) throws IllegalArgumentException { final long absoluteMaximumSize = getAbsoluteMaximumSize(); checkArgument(maxSizeBytes >= 0 && maxSizeBytes <= absoluteMaximumSize, "Cache max size must be between 0 and %s, got %s", absoluteMaximumSize, maxSizeBytes); SharedCache cache = SharedCache.build(maxSizeBytes); SharedCache old = _SHARED_CACHE; _SHARED_CACHE = cache; if (old != null) { old.invalidateAll(); } this.currentMaxCacheSize = maxSizeBytes; }
_SHARED_CACHE = cache; if (old != null) { old.invalidateAll();
public @Test void testInvalidateAll() { cache1.invalidateAll(); verify(mockSharedCache, times(1)).invalidateAll(eq(cacheId1)); }
public @Test void testInvalidateAll() { cache1.invalidateAll(); verify(mockSharedCache, times(1)).invalidateAll(eq(cacheId1)); }
public @Test void testInvalidateAllForPrefix() { final int L1Capacity = 10; SharedCache cache = SharedCache.build(L1Capacity, 16 * 1024 * 1024); List<RevObject> objects = createObjects(100); objects.forEach((o) -> cache.put(repo1Id.create(o.getId()), o)); objects.forEach((o) -> cache.put(repo2Id.create(o.getId()), o)); objects.forEach((o) -> assertNotNull(cache.getIfPresent(repo1Id.create(o.getId())))); objects.forEach((o) -> assertNotNull(cache.getIfPresent(repo2Id.create(o.getId())))); cache.invalidateAll(repo2Id); objects.forEach((o) -> assertNull(cache.getIfPresent(repo2Id.create(o.getId())))); objects.forEach((o) -> assertNotNull(cache.getIfPresent(repo1Id.create(o.getId())))); cache.invalidateAll(repo1Id); objects.forEach((o) -> assertNull(cache.getIfPresent(repo1Id.create(o.getId())))); }
@Ignore // too fragile depending on the jvm test heap public @Test void testInvalidateAllForPrefix() { final int L1Capacity = 10; cache = createCache(L1Capacity, 32 * 1024 * 1024); List<RevObject> objects = createObjects(100); objects.forEach((o) -> cache.put(repo1Id.create(o.getId()), o)); objects.forEach((o) -> cache.put(repo2Id.create(o.getId()), o)); objects.forEach((o) -> assertNotNull(cache.getIfPresent(repo1Id.create(o.getId())))); objects.forEach((o) -> assertNotNull(cache.getIfPresent(repo2Id.create(o.getId())))); cache.invalidateAll(repo2Id); objects.forEach((o) -> assertNull(cache.getIfPresent(repo2Id.create(o.getId())))); objects.forEach((o) -> assertNotNull(cache.getIfPresent(repo1Id.create(o.getId())))); cache.invalidateAll(repo1Id); objects.forEach((o) -> assertNull(cache.getIfPresent(repo1Id.create(o.getId())))); }
public @Test void testInvalidateAll() { final int L1Capacity = 10; SharedCache cache = SharedCache.build(L1Capacity, 16 * 1024 * 1024); List<RevObject> objects = createObjects(500); objects.forEach((o) -> cache.put(repo1Id.create(o.getId()), o)); objects.forEach((o) -> cache.put(repo2Id.create(o.getId()), o)); objects.forEach((o) -> assertNotNull(cache.getIfPresent(repo1Id.create(o.getId())))); objects.forEach((o) -> assertNotNull(cache.getIfPresent(repo2Id.create(o.getId())))); cache.invalidateAll(); objects.forEach((o) -> assertNull(cache.getIfPresent(repo2Id.create(o.getId())))); objects.forEach((o) -> assertNull(cache.getIfPresent(repo1Id.create(o.getId())))); }
@Ignore // too fragile depending on the jvm test heap public @Test void testInvalidateAll() { final int L1Capacity = 10; cache = createCache(L1Capacity, 32 * 1024 * 1024); List<RevObject> objects = createObjects(500); objects.forEach((o) -> cache.put(repo1Id.create(o.getId()), o)); objects.forEach((o) -> cache.put(repo2Id.create(o.getId()), o)); objects.forEach((o) -> assertNotNull(cache.getIfPresent(repo1Id.create(o.getId())))); objects.forEach((o) -> assertNotNull(cache.getIfPresent(repo2Id.create(o.getId())))); cache.invalidateAll(); objects.forEach((o) -> assertNull(cache.getIfPresent(repo2Id.create(o.getId())))); objects.forEach((o) -> assertNull(cache.getIfPresent(repo1Id.create(o.getId())))); }