Apache Solr open-source search software
SOLR-667 -- Making markAndSweep method public
Shalin Shekhar Mangar39e750d4b984
diff --git a/src/java/org/apache/solr/common/util/ConcurrentLRUCache.java b/src/java/org/apache/solr/common/util/ConcurrentLRUCache.javaindex 3b92d9d73f4..839aff99f06 100644--- a/src/java/org/apache/solr/common/util/ConcurrentLRUCache.java+++ b/src/java/org/apache/solr/common/util/ConcurrentLRUCache.java@@ -11,7 +11,7 @@ import java.util.concurrent.locks.ReentrantLock;/*** A LRU cache implementation based upon ConcurrentHashMap and other techniques to reduce* contention and synchronization overhead to utilize multiple CPU cores more effectively.- *+ * <p/>* Note that the implementation does not follow a true LRU (least-recently-used) eviction* strategy. Instead it strives to remove least recently used items but when the initial* cleanup does not remove enough items to reach the 'acceptableWaterMark' limit, it can@@ -104,7 +104,18 @@ public class ConcurrentLRUCache {return oldCacheEntry == null ? null : oldCacheEntry.value;}- private void markAndSweep() {+ /**+ * Removes items from the cache to bring the size down+ * to an acceptable value ('acceptableWaterMark').+ * <p/>+ * It is done in two stages. In the first stage, least recently used items are evicted.+ * If, after the first stage, the cache size is still greater than 'acceptableSize'+ * config parameter, the second stage takes over.+ * <p/>+ * The second stage is more intensive and tries to bring down the cache size+ * to the 'minSize' config parameter.+ */+ public void markAndSweep() {if (!markAndSweepLock.tryLock()) return;try {int size = stats.size.get();