コード例 #1
0
ファイル: Dao.java プロジェクト: seba9087/viaja-facil
 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;
   }
 }
コード例 #2
0
 /** 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);
   }
 }
コード例 #3
0
ファイル: TaskDao.java プロジェクト: azizdeves/knightyusuf
 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;
 }
コード例 #4
0
ファイル: TennisCache.java プロジェクト: geda/Tennis-Cadolles
  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);
    }
  }