MCPcopy Create free account
hub / github.com/antlr/codebuff / evictEntries

Method evictEntries

output/java_guava/1.4.17/LocalCache.java:2749–2770  ·  view source on GitHub ↗

Performs eviction if the segment is over capacity. Avoids flushing the entire cache if the newest entry exceeds the maximum weight all on its own. @param newest the most recently added entry

(ReferenceEntry<K, V> newest)

Source from the content-addressed store, hash-verified

2747 */
2748
2749 @GuardedBy("this")
2750 void evictEntries(ReferenceEntry<K, V> newest) {
2751 if (!map.evictsBySize()) {
2752 return;
2753 }
2754 drainRecencyQueue();
2755
2756 // If the newest entry by itself is too heavy for the segment, don't bother evicting
2757 // anything else, just that
2758 if (newest.getValueReference().getWeight() > maxSegmentWeight) {
2759 if (!removeEntry(newest, newest.getHash(), RemovalCause.SIZE)) {
2760 throw new AssertionError();
2761 }
2762 }
2763
2764 while (totalWeight > maxSegmentWeight) {
2765 ReferenceEntry<K, V> e = getNextEvictable();
2766 if (!removeEntry(e, e.getHash(), RemovalCause.SIZE)) {
2767 throw new AssertionError();
2768 }
2769 }
2770 }
2771
2772 // TODO(fry): instead implement this with an eviction head
2773

Callers 4

putMethod · 0.95
replaceMethod · 0.95
storeLoadedValueMethod · 0.95
refreshMethod · 0.95

Calls 7

drainRecencyQueueMethod · 0.95
removeEntryMethod · 0.95
getNextEvictableMethod · 0.95
getWeightMethod · 0.65
getValueReferenceMethod · 0.65
getHashMethod · 0.65
evictsBySizeMethod · 0.45

Tested by

no test coverage detected