Package net.sf.ehcache

Examples of net.sf.ehcache.Ehcache


   * @see AbstractCacheProviderFacade#onRemoveFromCache(Serializable,
   *CachingModel)
   */
  protected void onRemoveFromCache(Serializable key, CachingModel model)
      throws CacheException {
    Ehcache cache = getCache(model);

    try {
      cache.remove(key);

    } catch (Exception exception) {
      throw new CacheAccessException(exception);
    }
  }
View Full Code Here


        cacheManager = EHCacheManagerHolder.getCacheManager(bus, configFileURL);
        // Cannot overflow to disk as SecurityToken Elements can't be serialized
        CacheConfiguration cc = EHCacheManagerHolder.getCacheConfiguration(key, cacheManager)
            .overflowToDisk(false); //tokens not writable
       
        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);
       
        // Set the TimeToLive value from the CacheConfiguration
        ttl = cc.getTimeToLiveSeconds();
    }
View Full Code Here

            cacheManager = EHCacheUtil.createCacheManager(conf);
        }
       
        CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(CACHE_KEY, cacheManager);
       
        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);
    }
View Full Code Here

  @Test
  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

  @Test
  public void testSizing() {
    Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
    CacheManager cacheManager = CacheManager.getInstance();
    Ehcache ehcache = cacheManager.getEhcache("testCache");
    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

  @Test
  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);
      Assert.assertTrue("CacheException expected for DirectMemory OffHeap Memory Exceeded", true);
View Full Code Here

            cacheManager = CacheManager.create(conf);
        }
       
        CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(key, cacheManager);
       
        Ehcache newCache = new Cache(cc);
        cache = cacheManager.addCacheIfAbsent(newCache);
    }
View Full Code Here

                + "DELETE FROM acl_class;" + "DELETE FROM acl_sid;";
        jdbcTemplate.execute(query);
    }

    private Ehcache getCache() {
        Ehcache cache = cacheManager.getCache("basiclookuptestcache");
        cache.removeAll();
        return cache;
    }
View Full Code Here

        cacheManager.removalAll();
        cacheManager.shutdown();
    }

    private Ehcache getCache() {
        Ehcache cache = cacheManager.getCache("ehcacheusercachetests");
        cache.removeAll();

        return cache;
    }
View Full Code Here

        EhCacheBasedUserCache cache = new EhCacheBasedUserCache();

        cache.afterPropertiesSet();
        fail("Should have thrown IllegalArgumentException");

        Ehcache myCache = getCache();
        cache.setCache(myCache);
        assertEquals(myCache, cache.getCache());
    }
View Full Code Here

TOP

Related Classes of net.sf.ehcache.Ehcache

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.