Ejemplo n.º 1
0
 public static String getTextContent(String fkey) {
   /*
     	if ((System.currentTimeMillis() - last_clear_time) > 5 * 1000)
      	{
      		clearContent();
      		last_clear_time = System.currentTimeMillis();
      	}
   */
   if (cache.containsKey(fkey)) {
     TextCacheEntry fentry = (TextCacheEntry) (cache.get(fkey));
     if (fentry.getLoadTime() > System.currentTimeMillis()) return fentry.getContent();
   }
   return null;
 }
Ejemplo n.º 2
0
 public static synchronized void clearContent() {
   if ((System.currentTimeMillis() - last_clear_time) > 5 * 1000) {
     long currtime = System.currentTimeMillis();
     if (cache.size() > 0) {
       Object keyarr[] = cache.keySet().toArray();
       for (int i = 0; i < keyarr.length; i++) {
         TextCacheEntry fentry = (TextCacheEntry) (cache.get(keyarr[i]));
         if (fentry != null && fentry.getLoadTime() < currtime) {
           cache.remove(keyarr[i]);
         }
       }
     }
     last_clear_time = System.currentTimeMillis();
   }
 }