Package net.sf.ehcache

Examples of net.sf.ehcache.Element


   @Override
   public Object get(String region, String key)
   {
      Cache cache = getCacheRegion(region);
      Element element = cache.get(key);
      if (element != null)
      {
         return element.getObjectValue();
      }
      else
      {
         return null;
      }
View Full Code Here


            cache.dispose();
        }
    }

    public Object get(Object key) {
        Element element = cache.get(key);

        if (element != null) {
            return element.getObjectValue();
        }

        return null;
    }
View Full Code Here

        if (expired != null) {
            ttl = (int) (expired.getTime() - System.currentTimeMillis()) / 1000;
        }

        Element element = new Element(key, value, 0, ttl);

        cache.putQuiet(element);
    }
View Full Code Here

    }

    @Test
    public void measuresPuts() throws Exception {
        cache.put(new Element("woo", "whee"));

        assertThat(registry.timer(name(Cache.class, "test-config", "puts")).getCount())
                .isEqualTo(1);
    }
View Full Code Here

    @Test
    public void measuresGetsAndPuts() throws Exception {
        cache.get("woo");

        cache.put(new Element("woo", "whee"));

        final Timer gets = registry.timer(name(Cache.class, "test", "gets"));

        assertThat(gets.getCount())
                .isEqualTo(1);
View Full Code Here

   * @see AbstractIntegrationTests#assertCacheWasFlushed()
   */
  protected void assertCacheWasFlushed() throws Exception {
    setUpCacheManager();
    int index = 0;
    Element element = getCacheElement(index);
    assertCacheEntryFromCacheIsNull(element, getKeyAndModel(index).key);
  }
View Full Code Here

   * @see AbstractIntegrationTests#assertObjectWasCached(Object, int)
   */
  protected void assertObjectWasCached(Object expectedCachedObject,
      int keyAndModelIndex) throws Exception {
    setUpCacheManager();
    Element element = getCacheElement(keyAndModelIndex);
    assertEquals(expectedCachedObject, element.getValue());
  }
View Full Code Here

   * <code>{@link EhCacheFacade#onFlushCache(org.springmodules.cache.FlushingModel)}</code>
   * flushes the cache specified in the given cache model.
   */
  public void testOnFlushCache() throws Exception {
    setUpCache();
    cache.put(new Element(KEY, "A Value"));
    cacheFacade.onFlushCache(flushingModel);
    Object cachedValue = cache.get(KEY);
    assertNull("The cache '" + CACHE_NAME + "' should be empty", cachedValue);
  }
View Full Code Here

    cacheControl.verify();
  }

  public void testOnFlushCacheWhenCacheIsNotFound() {
    setUpCache();
    cache.put(new Element(KEY, "A Value"));
    flushingModel.setCacheNames("NonExistingCache");

    try {
      cacheFacade.onFlushCache(flushingModel);
      fail();
View Full Code Here

   */
  public void testOnGetFromCache() throws Exception {
    setUpCache();

    String expected = "An Object";
    cache.put(new Element(KEY, expected));

    Object cachedObject = cacheFacade.onGetFromCache(KEY, cachingModel);
    assertEquals(expected, cachedObject);
  }
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.