Beispiel #1
0
 public int addAndCheckSearchForIp(String ip, int mode) {
   String functionName = "addAndCheckSearchForIp()";
   Cache cache;
   Map<String, Integer> props = new HashMap<String, Integer>();
   props.put(GCacheFactory.EXPIRATION_DELTA, 600); // 10 minutes
   if (Utils.isUserInSpecialACL()) {
     //        	System.err.println("No limit for user: "******"(" +
     // Utils.getUser().getNickname() + ")");
     Logger.getLogger(location)
         .log(
             Level.INFO,
             functionName
                 + ": No limit for user: "******"("
                 + Utils.getUser().getNickname()
                 + ")");
     return 1;
   }
   try {
     String key = "requestCounter:" + mode + ":" + ip;
     CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
     cache = cacheFactory.createCache(props);
     Integer counter = new Integer(1);
     Integer o = (Integer) cache.get(key);
     if (o != null) {
       counter = counter + o;
     }
     cache.put(key, counter);
     return counter;
   } catch (CacheException e) {
     Logger.getLogger(location).log(Level.SEVERE, functionName + ": caching error: " + e);
     return -1;
   }
 }
 /** Private default constructor. */
 private ArticleCache() throws BackendException {
   try {
     CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
     this.cache = cacheFactory.createCache(Collections.emptyMap());
   } catch (CacheException e) {
     throw new BackendException(e);
   }
 }
Beispiel #3
0
 public static Cache getCache() {
   if (cache != null) return cache;
   try {
     CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
     cache = cacheFactory.createCache(Collections.emptyMap());
   } catch (CacheException e) {
     // ...
   }
   return cache;
 }
Beispiel #4
0
  private TennisCache() {
    try {

      CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();

      cache = cacheFactory.createCache(Collections.emptyMap());

    } catch (CacheException e) {

      log.log(Level.SEVERE, "error lors de la creation du cache", e);
    }
  }