From ca93e370fc031ccdedc0484ff3bec51595ed3963 Mon Sep 17 00:00:00 2001 From: Adam Heath Date: Thu, 1 Apr 2010 04:36:03 +0000 Subject: [PATCH] In setLru, if memoryTable is a ConcurrentLinkedHashMap, then just call setCapacity on it, which will cause the oldest entries to be removed when the size is lowered. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@929821 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/ofbiz/base/util/cache/CacheLineTable.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java b/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java index 390cf2591e..5e417528e5 100644 --- a/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java +++ b/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java @@ -294,8 +294,18 @@ public class CacheLineTable implements Serializable { Map> oldmap = this.memoryTable; if (newSize > 0) { - this.memoryTable = ConcurrentLinkedHashMap.create(ConcurrentLinkedHashMap.EvictionPolicy.LRU, newSize); + if (this.memoryTable instanceof ConcurrentLinkedHashMap) { + Debug.logInfo("a setLru(" + newSize + ")", module); + Debug.logInfo("before " + this.memoryTable.keySet(), module); + ((ConcurrentLinkedHashMap) this.memoryTable).setCapacity(newSize); + Debug.logInfo("after " + this.memoryTable.keySet(), module); + return; + } else { + Debug.logInfo("b setLru(" + newSize + ")", module); + this.memoryTable = ConcurrentLinkedHashMap.create(ConcurrentLinkedHashMap.EvictionPolicy.LRU, newSize); + } } else { + Debug.logInfo("c setLru(" + newSize + ")", module); this.memoryTable = FastMap.newInstance(); }