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
This commit is contained in:
Adam Heath
2010-04-01 04:36:03 +00:00
parent e5b8e12d8a
commit ca93e370fc
@@ -294,8 +294,18 @@ public class CacheLineTable<K, V> implements Serializable {
Map<Object, CacheLine<V>> 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();
}