/[projects]/android/MarketStats/src/dk/thoerup/marketstats/ShowStats.java
ViewVC logotype

Diff of /android/MarketStats/src/dk/thoerup/marketstats/ShowStats.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 664 by torben, Fri Apr 23 15:25:52 2010 UTC revision 669 by torben, Mon Apr 26 07:57:45 2010 UTC
# Line 30  public class ShowStats extends HttpServl Line 30  public class ShowStats extends HttpServl
30    
31          String login;          String login;
32          String password;          String password;
33            
34            MemcachedClient memcache = null;
35    
36    
37          @Override          @Override
# Line 38  public class ShowStats extends HttpServl Line 40  public class ShowStats extends HttpServl
40    
41                  login = getServletContext().getInitParameter("login");                  login = getServletContext().getInitParameter("login");
42                  password = getServletContext().getInitParameter("password");                  password = getServletContext().getInitParameter("password");
43                    
44                    try {
45                            memcache = new MemcachedClient(new InetSocketAddress("localhost", 11211));
46                    } catch (IOException e) {
47                            throw new ServletException(e);
48                    }
49          }          }
50    
51          protected String doLookup(String appId) throws IOException {          protected String doLookup(String appId) throws IOException {
52                  MemcachedClient c = new MemcachedClient(new InetSocketAddress("localhost", 11211));                  
   
53    
54                  String key = "marketstats:" + appId;                  String key = "marketstats:" + appId;
55                  String response = (String) c.get(key);                  String response = (String) memcache.get(key);
56    
57                  if (response == null) {                  if (response == null) {
58                          response = doLookupWorker(appId);                          response = doLookupWorker(appId);
59                          c.set(key, TIMEOUT, response);                          memcache.set(key, TIMEOUT, response);
60                          response += "<!-- new lookup -->";                          response += "<!-- new lookup -->";
61                  } else {                  } else {
62                          response += "<!-- from memcached -->";                          response += "<!-- from memcached -->";
# Line 82  public class ShowStats extends HttpServl Line 89  public class ShowStats extends HttpServl
89                          session.flush();                          session.flush();
90                          start +=10;                          start +=10;
91                                                    
92                          if (start >= 30)                          if (start >= 20)
93                                  break; //emergency brake                                  break; //emergency brake
94                                                    
95                  } while ( start < commentsCb.getEntryCount() );                  } while ( start < commentsCb.getEntryCount() );
# Line 128  public class ShowStats extends HttpServl Line 135  public class ShowStats extends HttpServl
135                          sb.append("\n");                          sb.append("\n");
136    
137                  }                  }
138                  sb.append("Comments: " + commentBeans.size() );                  sb.append("Comments: " + commentBeans.size() + "\n");
139                    sb.append("Cache.Timeout=" + TIMEOUT/60 + " minutes");
140    
141    
142                  return sb.toString();                  return sb.toString();

Legend:
Removed from v.664  
changed lines
  Added in v.669

  ViewVC Help
Powered by ViewVC 1.1.20