Skip to content

Commit

Permalink
remove removalNotification
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Alfonsi <[email protected]>
  • Loading branch information
Peter Alfonsi committed Feb 26, 2025
1 parent b498909 commit 128506d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,6 @@ public void put(ICacheKey<K> key, V value) {
}
updateStatsOnPut(cacheValueTuple.v2(), key, value);
}
} else {
// Signal to the caller that the key didn't enter the cache by sending a removal notification.
removalListener.onRemoval(new RemovalNotification<>(key, value, RemovalReason.EXPLICIT));
}
}

Expand Down Expand Up @@ -403,11 +400,6 @@ private Tuple<V, Tuple<Boolean, Boolean>> compute(
throw new IllegalStateException(ex);
}
}
if (wasRejectedByPolicy) {
// Signal to the caller that the key didn't enter the cache by sending a removal notification.
// This case does not count as a cache miss.
removalListener.onRemoval(new RemovalNotification<>(key, value, RemovalReason.EXPLICIT));
}
return new Tuple<>(value, new Tuple<>(wasCacheMiss, wasRejectedByPolicy));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ public CachedQueryResult.PolicyValues apply(String s) {
expectedKeys++;
}
}
assertEquals(keyValueMap.size() - expectedKeys, removalListener.evictionsMetric.count());
assertEquals(0, removalListener.evictionsMetric.count());
assertEquals(0, getHitsForTier(tieredSpilloverCache, TIER_DIMENSION_VALUE_ON_HEAP));
assertEquals(expectedKeys, tieredSpilloverCache.count());

Expand Down Expand Up @@ -1657,8 +1657,7 @@ public void testEntryPoliciesWithPut() throws Exception {

assertEquals(0, getEvictionsForTier(tieredSpilloverCache, TIER_DIMENSION_VALUE_ON_HEAP));
assertEquals(expectedKeys, getTotalStatsSnapshot(tieredSpilloverCache).getItems());
assertEquals(keyValuePairs.size() - expectedKeys, removalListener.evictionsMetric.count()); // Policy rejects should send a removal
// notification
assertEquals(0, removalListener.evictionsMetric.count());
}

public void testEntryPoliciesConcurrentlyWithComputeIfAbsent() throws Exception {
Expand Down Expand Up @@ -1745,8 +1744,7 @@ public void testEntryPoliciesConcurrentlyWithComputeIfAbsent() throws Exception

assertEquals(0, getEvictionsForTier(tieredSpilloverCache, TIER_DIMENSION_VALUE_ON_HEAP));
assertEquals(expectedKeys, getTotalStatsSnapshot(tieredSpilloverCache).getItems());
// Policy rejects should send a removal notification every time the caller attempts to put them in
assertEquals((keyValuePairs.size() - expectedKeys) * numRepetitionsPerKey, removalListener.evictionsMetric.count());
assertEquals(0, removalListener.evictionsMetric.count());
}

public void testPutWithDiskCacheDisabledSetting() throws Exception {
Expand Down

0 comments on commit 128506d

Please sign in to comment.