/[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 757 by torben, Thu May 27 08:51:59 2010 UTC revision 762 by torben, Thu May 27 11:30:16 2010 UTC
# Line 4  import java.io.IOException; Line 4  import java.io.IOException;
4  import java.io.PrintWriter;  import java.io.PrintWriter;
5  import java.net.InetSocketAddress;  import java.net.InetSocketAddress;
6  import java.util.ArrayList;  import java.util.ArrayList;
 import java.util.Collections;  
7  import java.util.Date;  import java.util.Date;
8  import java.util.Locale;  import java.util.Locale;
9    import java.util.concurrent.TimeUnit;
10  import java.util.logging.Logger;  import java.util.logging.Logger;
11    
12  import javax.servlet.ServletException;  import javax.servlet.ServletException;
# Line 48  public class ShowStats extends HttpServl Line 48  public class ShowStats extends HttpServl
48                  }                  }
49          }          }
50    
51            @Override
52            public void destroy() {
53                    super.destroy();
54                    
55                    memcache.shutdown(3, TimeUnit.SECONDS);
56                    memcache = null;
57            }
58    
59          protected String doLookup(String query) throws IOException {          protected String doLookup(String query) throws IOException {
60                                    
61    
62                  String key = "marketstats:" + query;                  String key = "marketstats:" + query.replace(' ', '_');
63                  String response = (String) memcache.get(key);                  String response = (String) memcache.get(key);
64    
65                  if (response == null) {                  if (response == null) {
# Line 138  public class ShowStats extends HttpServl Line 146  public class ShowStats extends HttpServl
146                          }                          }
147                          sb.append("Comments: " + commentBeans.size() + "\n");                          sb.append("Comments: " + commentBeans.size() + "\n");
148                  }                  }
149                  sb.append("Cache.Timeout=" + TIMEOUT/60 + " minutes");                            sb.append("<!--Cache.Timeout=" + TIMEOUT/60 + " minutes-->\n");        
150    
151    
152                  return sb.toString();                  return sb.toString();
# Line 149  public class ShowStats extends HttpServl Line 157  public class ShowStats extends HttpServl
157    
158                  response.setContentType("text/html");                  response.setContentType("text/html");
159                  PrintWriter out = response.getWriter();                  PrintWriter out = response.getWriter();
160                  out.print( "<html><body><pre>" + doLookupWorker(query) + "</pre></body></html>" );                  out.print( "<html><body><pre>" + doLookup(query) + "</pre></body></html>" );
161          }          }
162    
163  }  }

Legend:
Removed from v.757  
changed lines
  Added in v.762

  ViewVC Help
Powered by ViewVC 1.1.20