svn commit: r929846 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache: UtilCache.java test/UtilCacheTests.java

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

svn commit: r929846 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache: UtilCache.java test/UtilCacheTests.java

doogie-3
Author: doogie
Date: Thu Apr  1 04:52:39 2010
New Revision: 929846

URL: http://svn.apache.org/viewvc?rev=929846&view=rev
Log:
Add a new method, erase(), which just clears out the stored entries,
without clearing any counters.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/UtilCache.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.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=929846&r1=929845&r2=929846&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 Thu Apr  1 04:52:39 2010
@@ -547,7 +547,7 @@ public class UtilCache<K, V> implements
     }
 
     /** Removes all elements from this cache */
-    public synchronized void clear() {
+    public synchronized void erase() {
         if (fileTable != null) {
             // FIXME: erase from memory too
             Set<Object> keys = new HashSet<Object>();
@@ -577,6 +577,10 @@ public class UtilCache<K, V> implements
                 it.remove();
             }
         }
+    }
+
+    public void clear() {
+        erase();
         clearCounters();
     }
 

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java?rev=929846&r1=929845&r2=929846&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java Thu Apr  1 04:52:39 2010
@@ -288,7 +288,7 @@ public class UtilCacheTests extends Gene
             assertHasSingleKey(cache, "one", "only");
 
             wantedListener.noteKeyRemoval(cache, "one", "only");
-            assertEquals("remove", "only", cache.remove("one"));
+            cache.erase();
             assertNoSingleKey(cache, "one");
             assertEquals("byteSize", origByteSize, cache.getSizeInBytes());
 
@@ -309,7 +309,8 @@ public class UtilCacheTests extends Gene
         assertEquals("remove-miss", 10, cache.getRemoveMissCount());
         cache.removeListener(gotListener);
         assertEquals("listener", wantedListener, gotListener);
-        cache.clear();
+        UtilCache.clearCache(cache.getName());
+        UtilCache.clearCache(":::" + cache.getName());
     }
 
     public void testBasicDisk() throws Exception {