Author: doogie
Date: Wed Oct 17 13:00:49 2007
New Revision: 585656
URL:
http://svn.apache.org/viewvc?rev=585656&view=revLog:
Add helper method for finding UtilCaches by name. Closes
https://issues.apache.org/jira/browse/OFBIZ-1301Modified:
ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/cache/UtilCache.java
Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/cache/UtilCache.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/cache/UtilCache.java?rev=585656&r1=585655&r2=585656&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/cache/UtilCache.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/cache/UtilCache.java Wed Oct 17 13:00:49 2007
@@ -664,7 +664,7 @@
/** Checks for a non-expired key in a specific cache */
public static boolean validKey(String cacheName, Object key) {
- UtilCache cache = (UtilCache) utilCacheTable.get(cacheName);
+ UtilCache cache = findCache(cacheName);
if (cache != null) {
if (cache.containsKey(key))
return true;
@@ -687,10 +687,14 @@
}
public static void clearCache(String cacheName) {
+ UtilCache cache = findCache(cacheName);
+ if (cache == null) return;
+ cache.clear();
+ }
+
+ public static UtilCache findCache(String cacheName) {
synchronized (UtilCache.utilCacheTable) {
- UtilCache cache = (UtilCache) UtilCache.utilCacheTable.get(cacheName);
- if (cache == null) return;
- cache.clear();
+ return (UtilCache) UtilCache.utilCacheTable.get(cacheName);
}
}
}