svn commit: r929821 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r929821 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java

doogie-3
Author: doogie
Date: Thu Apr  1 04:36:03 2010
New Revision: 929821

URL: http://svn.apache.org/viewvc?rev=929821&view=rev
Log:
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.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java?rev=929821&r1=929820&r2=929821&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/CacheLineTable.java Thu Apr  1 04:36:03 2010
@@ -294,8 +294,18 @@ public class CacheLineTable<K, V> implem
         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();
         }