Author: jleroux
Date: Tue May 25 13:38:39 2010
New Revision: 948037
URL:
http://svn.apache.org/viewvc?rev=948037&view=revLog:
Fix a bug introduced while updating ConcurrentLinkedHashMap implementation at r947993. Reported by Christian on dev ML.
I used the default Weigher (see JavaDoc)
BTW this new implementation is really faster (tried with ArtifactInfo)
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java?rev=948037&r1=948036&r2=948037&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java Tue May 25 13:38:39 2010
@@ -38,7 +38,9 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-import com.reardencommerce.kernel.collections.shared.evictable.ConcurrentLinkedHashMap;
+import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
+import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.Builder;
+import com.googlecode.concurrentlinkedhashmap.Weighers;
import javolution.util.FastList;
import javolution.util.FastMap;
@@ -143,7 +145,9 @@ public class UtilCache<K, V> implements
if (maxMemSize == 0) {
memoryTable = new ConcurrentHashMap<Object, CacheLine<V>>();
} else {
- memoryTable = ConcurrentLinkedHashMap.create(ConcurrentLinkedHashMap.EvictionPolicy.LRU, maxMemSize);
+ memoryTable = new Builder<Object, CacheLine<V>>()
+ .maximumWeightedCapacity(maxMemSize)
+ .build();
}
if (this.useFileSystemStore) {
// create the manager the first time it is needed
@@ -668,7 +672,9 @@ public class UtilCache<K, V> implements
((ConcurrentLinkedHashMap) this.memoryTable).setCapacity(newInMemory);
return;
} else {
- this.memoryTable = ConcurrentLinkedHashMap.create(ConcurrentLinkedHashMap.EvictionPolicy.LRU, newInMemory);
+ this.memoryTable =new Builder<Object, CacheLine<V>>()
+ .maximumWeightedCapacity(newInMemory)
+ .build();
}
} else {
this.memoryTable = new ConcurrentHashMap<Object, CacheLine<V>>();