Package net.sf.ehcache

Examples of net.sf.ehcache.Element


  public Ehcache getCache() {
    return cache;
  }

  public void put(CasAuthentication token) {
    Element element = new Element(token.getCredentials().toString(), token);
    logger.debug("Cache put: {}", element.getKey());
    cache.put(element);
  }
View Full Code Here


    }
  }
 
  // ---- cache get, set, remove
  public Serializable get(String key) {
    Element elem;
    try {
      synchronized (cache) {//cluster_ok by definition of this class as used in single vm
        elem = cache.get(key);       
      }
    } catch (IllegalStateException e) {
      throw new OLATRuntimeException("cache state error for cache "+cache.getName(), e);
    } catch (CacheException e) {
      throw new OLATRuntimeException("cache error for cache "+cache.getName(), e);
    }
    return elem == null? null : elem.getValue();
  }
View Full Code Here

    // update is the same as put for the singlevm mode
    doPut(key, value);
  }
 
  private void doPut(String key, Serializable value) {
    Element element = new Element(key, value);
    synchronized (cache) {//cluster_ok by definition of this class as used in single vm
      cache.put(element);
    }   
  }
View Full Code Here

  public void updateMulti(String[] keys, Serializable[] values) {
    int len = keys.length;
    synchronized (cache) {//cluster_ok by definition of this class as used in single vm
      for (int i = 0; i < len; i++) {
        Element element = new Element(keys[i], values[i]);       
        cache.put(element);
      }
    }
  }
View Full Code Here

  }

  public void add(Serializable path, Serializable value) {
    if (cache == null) return;

    cache.put(new Element(path, value));
    addElements.incrementAndGet();
  }
View Full Code Here

   * @return  CacheDirectory
   */
  public CacheDirectory get(String path, boolean recheck) {
    requests.incrementAndGet();

    Element e = cache.get(path);
    if (e != null) {
      if (cacheLog.isDebugEnabled()) cacheLog.debug("thredds.filesystem.CacheManager found in cache; path =" + path);

      CacheDirectory m = (CacheDirectory) e.getValue();
      if (m != null) { // not sure how a null m gets in here
        if (!recheck) return m;

        File f = new File(m.getPath()); // check if file exists and when last modified
        if (!f.exists()) {
          cache.put(new Element(path, null));
          return null;
        }

        boolean modified = (f.lastModified() > m.lastModified);
        if (modified && cacheLog.isDebugEnabled())
          cacheLog.debug("thredds.filesystem.CacheManager modified diff = "+ (f.lastModified() - m.lastModified) + "; path=" + path);

        if (!modified) {
          hits.incrementAndGet();
          return m;
        }
        // if modified, null it out and reread it
        cache.put(new Element(path, null));
      }
    }

    File p = new File(path);
    if (!p.exists()) return null;
View Full Code Here

  public void showKeys() {
    List keys = cache.getKeys();
    Collections.sort(keys);
    for (Object key : keys) {
      Element elem = cache.get(key);
      System.out.printf(" %40s == %s%n", key, elem);
    }
  }
View Full Code Here

    }

    public void put(String region, String key, String content) {
        if (!caches.containsKey(region))
            throw new IllegalStateException("can't put into uninitialized cache region: " + region);
        caches.get(region).put(new Element(key, content));
    }
View Full Code Here

    }

    public String get(String region, String key) {
        if (!caches.containsKey(region))
            throw new IllegalStateException("can't get from uninitialized cache region: " + region);
        Element result = caches.get(region).get(key);
        return result != null ? (String)result.getValue() : null;
    }
View Full Code Here

        this.statistics = stats;
    }

    @Override
    public void add(String user, String realm, Map<String, String> identities) {
        cache.put(new Element(user + "@" + realm, identities));
    }
View Full Code Here

TOP

Related Classes of net.sf.ehcache.Element

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.