Пример #1
0
 public Object get(Object key) throws CacheException {
   try {
     return cache.getFromCache(toString(key), refreshPeriod, cron);
   } catch (NeedsRefreshException e) {
     cache.cancelUpdate(toString(key));
     return null;
   }
 }
Пример #2
0
  /** Clears out service methods cache by calling adminstrators flushAll */
  protected void clearMethodCache() {
    LOG.info("clearing spring method cache ...");

    if (cacheAdminstrators != null) {
      for (GeneralCacheAdministrator cache : cacheAdminstrators) {
        cache.flushAll();
      }
    }
  }
Пример #3
0
 // 刷新所有缓存
 public String flush() {
   cacheManager.flushAll();
   flushCache();
   try {
     ServletContext servletContext = ServletActionContext.getServletContext();
     freemarkerManager.getConfiguration(servletContext).clearTemplateCache();
   } catch (TemplateException e) {
     e.printStackTrace();
   }
   return SUCCESS;
 }
Пример #4
0
  protected CacheManager(Configuration conf) {

    Properties p = new Properties();

    // use memory for caching
    boolean cacheMemory = conf.getBoolean("cache.memory", false);
    p.setProperty("cache.memory", Boolean.toString(cacheMemory));

    // the persistence class used
    String cachePersistenceClass =
        conf.get("cache.persistence.class", "org.apache.nutch.cache.CustomDiskPersistenceListener");
    p.setProperty("cache.persistence.class", cachePersistenceClass);

    // where to store cache files (if file cache used)
    String cachePath = conf.get("cache.path", ".");
    p.setProperty("cache.path", cachePath);

    // cacacity of cache (how many entries)
    int cacheCapacity = conf.getInt("cache.capacity", 1000);
    p.setProperty("cache.capacity", Integer.toString(cacheCapacity));

    cacheadmin = new GeneralCacheAdministrator(p);
    cache = cacheadmin.getCache();
  }
Пример #5
0
 public void destroy() throws CacheException {
   cache.destroy();
 }
Пример #6
0
 public void clear() throws CacheException {
   cache.flushAll();
 }
Пример #7
0
 public void remove(Object key) throws CacheException {
   cache.flushEntry(toString(key));
 }
Пример #8
0
 public void put(Object key, Object value) throws CacheException {
   cache.putInCache(toString(key), value);
 }
Пример #9
0
 public void setCacheCapacity(int cacheCapacity) {
   cache.setCacheCapacity(cacheCapacity);
 }