public Object get(Object key) throws CacheException { try { return cache.getFromCache(toString(key), refreshPeriod, cron); } catch (NeedsRefreshException e) { cache.cancelUpdate(toString(key)); return null; } }
/** 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(); } } }
// 刷新所有缓存 public String flush() { cacheManager.flushAll(); flushCache(); try { ServletContext servletContext = ServletActionContext.getServletContext(); freemarkerManager.getConfiguration(servletContext).clearTemplateCache(); } catch (TemplateException e) { e.printStackTrace(); } return SUCCESS; }
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(); }
public void destroy() throws CacheException { cache.destroy(); }
public void clear() throws CacheException { cache.flushAll(); }
public void remove(Object key) throws CacheException { cache.flushEntry(toString(key)); }
public void put(Object key, Object value) throws CacheException { cache.putInCache(toString(key), value); }
public void setCacheCapacity(int cacheCapacity) { cache.setCacheCapacity(cacheCapacity); }