Package net.sf.ehcache

Examples of net.sf.ehcache.Cache$CacheStatus


   * @param cache_name
   * @param key
   * @return
   */
  public static Serializable getObjectCached(String cache_name, Serializable key){
    Cache cache = getCache(cache_name);
    if(cache!=null){
      try {
        Element elem = cache.get(key);
        if(elem!=null && !cache.isExpired(elem))
          return elem.getValue();
      } catch (Exception e) {
        log.error("Get cache("+cache_name+") of "+key+" failed.", e);
      }
    }
View Full Code Here


   * @param cache_name
   * @param key
   * @param value
   */
  public synchronized static void putObjectCached(String cache_name, Serializable key, Serializable value){
    Cache cache = getCache(cache_name);
    if(cache!=null){
      try {
        cache.remove(key);
        Element elem = new Element(key, value);
        cache.put(elem);
      } catch (Exception e) {
        log.error("put cache("+cache_name+") of "+key+" failed.", e);
      }
    }
  }
View Full Code Here

   * @return
   * @throws IllegalStateException
   * @throws CacheException
   */
  public static Element getElement(String cache, Serializable key) throws IllegalStateException, CacheException{
    Cache cCache = getCache(cache);
    return cCache.get(key);
  }
View Full Code Here

   * @return
   * @throws IllegalStateException
   * @throws CacheException
   */
  public static Element getRssElement(Serializable key) throws IllegalStateException, CacheException{
    Cache cache = getRssCache();   
    return (cache!=null)?cache.get(key):null;
  }
View Full Code Here

    }

    public NonceVerifier createVerifier(int maxAge)
    {
        _cacheManager.removalAll();
        _cacheManager.addCache(new Cache("testCache", 100, false, false, maxAge, maxAge));

        EhcacheNonceVerifier nonceVerifier = new EhcacheNonceVerifier(maxAge);
        nonceVerifier.setCache(_cacheManager.getCache("testCache"));

        return nonceVerifier;
View Full Code Here

  public void setChildrenConfig(Map<String, CacheConfig> childrenConfig) {
    this.childrenConfig = childrenConfig;
  }

  private Cache doCreateCache(String cacheName) {
    return new Cache(
        cacheName, this.maxElementsInMemory, this.memoryStoreEvictionPolicy,
        this.overflowToDisk, this.diskStorePath, this.eternal, this.timeToLive, this.timeToIdle,
        this.diskPersistent, this.diskExpiryThreadIntervalSeconds, null);
  }
View Full Code Here

    addElements.incrementAndGet();
  }

  static public String show(String cacheName) {
    if (cacheManager == null) return "no cacheManager set";
    Cache cache = cacheManager.getCache(cacheName);
    if (cache == null) return "no cache named "+cacheName;
    Formatter f = new Formatter();
    f.format("Cache %s%n %s%n", cache, cache.getStatistics().toString());
    return f.toString();
  }
View Full Code Here

                        requiredCacheRegions.addAll(pluginModule.getFragmentCacheRegions());
                }
            }

            for (String cacheRegion : requiredCacheRegions) {
                Cache cache = EHCacheManager.instance().getCache(cacheRegion);
                if (cache == null) {
                    log.info("using default configuration for region '" + cacheRegion + "'");
                    manager.addCache(cacheRegion);
                    cache = manager.getCache(cacheRegion);
                    log.debug("started EHCache region: " + cacheRegion);
View Full Code Here

        TableEvent te = (TableEvent) event;
        String actionid = te.getActionId();
        if (actionid.equals("empty")) {
          int rowid = te.getRowId();
          String cname = cnames[rowid];
          Cache toEmpty = cm.getCache(cname);
         
          //provide dc as argument, this ensures that dc is disposed before newly created
          dc = activateYesNoDialog(ureq, null, translate("confirm.emptycache"), dc);
          //remember Cache to be emptied if yes is chosen
          dc.setUserObject(toEmpty);
          //activateYesNoDialog means that this controller listens to it, and dialog is shown on screen.
          //nothing further to do here!
          return;
        }
      }
    }
    else if (source == dc) {
      //the dialogbox is already removed from the gui stack - do not use getWindowControl().pop(); to remove dialogbox
      if (DialogBoxUIFactory.isYesEvent(event)) { // ok
        String cacheName = null;
        try {
          // delete cache
          Cache c = (Cache)dc.getUserObject();
          cacheName = c.getName();
          c.removeAll();
        } catch (IllegalStateException e) {
          // ignore
          log.error("Cannot remove Cache:"+cacheName, e);
        }
        // update tablemodel
View Full Code Here

    return cnames.length;
  }

  public Object getValueAt(int row, int col) {
    String cname = cnames[row];
    Cache c = cacheManager.getCache(cname);
    //todo: use Statistics stat = c.getStatistics();
    switch(col) {
      case 0: return cname;
      case 1: return c.isDiskPersistent()? Boolean.TRUE:Boolean.FALSE;
      case 2: return new Long(c.getHitCount());
      case 3: return new Long(c.getMissCountExpired());
      case 4: return new Long(c.getMissCountNotFound());
      case 5: return new Long(c.getKeysNoDuplicateCheck().size());
      case 6: return new Long(c.getTimeToIdleSeconds());
      case 7: return new Long(c.getTimeToLiveSeconds());
      case 8: return new Long(c.getMaxElementsInMemory());
      default: throw new AssertException("nonexisting column:"+col);
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.ehcache.Cache$CacheStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.