Package net.sf.ehcache

Examples of net.sf.ehcache.Element


        // return null for null entries
        if(entity == null) {
            return null;          
        }

        Element cacheElement = jidPresenceCache.get(entity);

        // return the value from presence cache
        if(cacheElement != null) {
            return (PresenceStanza)cacheElement.getObjectValue();
        }
        return null;
    }
View Full Code Here


   
    public void add(SecurityToken token) {
        if (token != null && !StringUtils.isEmpty(token.getId())) {
            int parsedTTL = getTTL(token);
            if (parsedTTL > 0) {
                Element element = new Element(token.getId(), token);
                element.setTimeToLive(parsedTTL);
                element.setTimeToIdle(parsedTTL);
                element.resetAccessStatistics();
                cache.put(element);
            }
        }
    }
View Full Code Here

   
    public void add(String identifier, SecurityToken token) {
        if (token != null && !StringUtils.isEmpty(identifier)) {
            int parsedTTL = getTTL(token);
            if (parsedTTL > 0) {
                Element element = new Element(identifier, token);
                element.setTimeToLive(parsedTTL);
                element.setTimeToIdle(parsedTTL);
                element.resetAccessStatistics();
                cache.put(element);
            }
        }
    }
View Full Code Here

    public Collection<SecurityToken> getExpiredTokens() {
        List<SecurityToken> expiredTokens = new ArrayList<SecurityToken>();
        @SuppressWarnings("unchecked")
        Iterator<String> ids = cache.getKeys().iterator();
        while (ids.hasNext()) {
            Element element = cache.get(ids.next());
            if (cache.isExpired(element)) {
                expiredTokens.add((SecurityToken)element.getObjectValue());
            }
        }
        return expiredTokens;
    }
View Full Code Here

        }
        return expiredTokens;
    }
   
    public SecurityToken getToken(String identifier) {
        Element element = cache.get(identifier);
        if (element != null && !cache.isExpired(element)) {
            return (SecurityToken)element.getObjectValue();
        }
        return null;
    }
View Full Code Here

   
    /**
     * Store an XKMSCacheToken in the Cache using the given key
     */
    public void put(String key, XKMSCacheToken cacheToken) {
        cache.put(new Element(key, cacheToken));
    }
View Full Code Here

    /**
     * Get an XKMSCacheToken from the cache matching the given key. Returns null if there
     * is no such XKMSCacheToken in the cache, or if the certificate has expired in the cache
     */
    public XKMSCacheToken get(String key) {
        Element element = cache.get(key);
        if (element != null && !element.isExpired()) {
            return (XKMSCacheToken)element.getObjectValue();
        }
        return null;
    }
View Full Code Here

  public void testPutRetreive() {
    Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
    CacheManager cacheManager = CacheManager.getInstance();
    Ehcache ehcache = cacheManager.getEhcache("testCache");

    ehcache.put(new Element("testKey", "testValue"));
    stats(ehcache);
    Assert.assertEquals("testValue", ehcache.get("testKey").getObjectValue());
  }
View Full Code Here

    for (int i = 0; i < 30000; i++) {
      if ((i % 1000) == 0) {
        System.out.println("heatbeat " + i);
        stats(ehcache);
      }
      ehcache.put(new Element(i, new byte[1024]));
    }
    stats(ehcache);
    Assert.assertTrue(true);
  }
View Full Code Here

  public void testOffHeapExceedMemory()
          throws IOException {
    Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
    CacheManager cacheManager = CacheManager.getInstance();
    Ehcache ehcache = cacheManager.getEhcache("testCache");
    Element element = null;
    try {
      for (int i = 0; i < 3000000; i++) {
        if ((i % 1000) == 0) {
          System.out.println("heatbeat 2 " + i);
          stats(ehcache);
        }
        element = new Element(i, new byte[1024]);
        ehcache.put(element);
      }
      Assert.fail("CacheException expected for DirectMemory OffHeap Memory Exceeded");
    } catch (CacheException e) {
      stats(ehcache);
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.