--- android/MarketStats/src/dk/thoerup/marketstats/ShowStats.java 2010/04/23 15:28:34 666 +++ android/MarketStats/src/dk/thoerup/marketstats/ShowStats.java 2010/04/25 20:53:06 667 @@ -30,6 +30,8 @@ String login; String password; + + MemcachedClient memcache = null; @Override @@ -38,18 +40,24 @@ login = getServletContext().getInitParameter("login"); password = getServletContext().getInitParameter("password"); + + try { + memcache = new MemcachedClient(new InetSocketAddress("localhost", 11211)); + } catch (IOException e) { + throw new ServletException(e); + } } protected String doLookup(String appId) throws IOException { - MemcachedClient c = new MemcachedClient(new InetSocketAddress("localhost", 11211)); + String key = "marketstats:" + appId; - String response = (String) c.get(key); + String response = (String) memcache.get(key); if (response == null) { response = doLookupWorker(appId); - c.set(key, TIMEOUT, response); + memcache.set(key, TIMEOUT, response); response += ""; } else { response += "";