details: /erp/devel/pi/rev/abe749f609f8
changeset: 9066:abe749f609f8
user: Stefan Hühner <stefan.huehner <at> openbravo.com>
date: Thu Dec 02 19:19:21 2010 +0100
summary: Fixed 15362: Speedup wad by caching many repeated queries.
Remove nearly 130.000 db-queries by using a small cache of around 350 entries
diffstat:
src-wad/src/org/openbravo/wad/WadUtility.java | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diffs (36 lines):
diff -r a9676a2a9f36 -r abe749f609f8
src-wad/src/org/openbravo/wad/WadUtility.java
--- a/src-wad/src/org/openbravo/wad/WadUtility.java Thu Dec 02 18:02:57
2010 +0100
+++ b/src-wad/src/org/openbravo/wad/WadUtility.java Thu Dec 02 19:19:21
2010 +0100
@@ -24,6 +24,7 @@
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Vector;
@@ -45,6 +46,9 @@
{ "^", " != " }, { "-", " != " } };
private static String[][] unions = { { "|", " || " }, { "&", " && " } };
+ // small cache to store mapping of <subRef + "-" + parentRef,classname>
+ private static Map<String, String> referenceClassnameCache = new
HashMap<String, String>();
+
public WadUtility() {
PropertyConfigurator.configure("log4j.lcf");
}
@@ -791,7 +795,13 @@
WADControl control;
try {
- classname = WadUtilityData.getReferenceClassName(conn, subRef,
parentRef);
+ // lookup value from cache, if not found, search in db and put into cache
+ String cacheKey = subRef + "-" + parentRef;
+ classname = referenceClassnameCache.get(cacheKey);
+ if (classname == null) {
+ classname = WadUtilityData.getReferenceClassName(conn, subRef,
parentRef);
+ referenceClassnameCache.put(cacheKey, classname);
+ }
} catch (ServletException e1) {
log4j.warn("Couldn't find reference classname ref " + parentRef + ",
subRef " + subRef, e1);
return new WADControl();
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits