@Test public void testReadThroughSimpleCase() { CacheManager manager = new CacheManager(); manager.removalAll(); CacheConfiguration config = new CacheConfiguration().name("sampleCacheReadThru").maxElementsInMemory(100).timeToIdleSeconds(8) .timeToLiveSeconds(8).overflowToDisk(false); manager.addCache(new Cache(config)); Ehcache cache = manager.getEhcache("sampleCacheReadThru"); ReadThroughCacheConfiguration readThroughConfig = new ReadThroughCacheConfiguration().modeGet(true).build(); ReadThroughCache decorator = new ReadThroughCache(cache, readThroughConfig); cache.registerCacheLoader(stringifyCacheLoader); Element got = cache.get(new Integer(1)); Assert.assertNull(got); got = decorator.get(new Integer(1)); Assert.assertNotNull(got); got = cache.get(new Integer(1)); Assert.assertNotNull(got); sleepySeconds(10); got = cache.get(new Integer(1)); Assert.assertNull(got); got = decorator.get(new Integer(1)); Assert.assertNotNull(got); got = cache.get(new Integer(1)); Assert.assertNotNull(got); manager.removalAll(); manager.shutdown(); }
@Override public Element get(Object key) throws IllegalStateException, CacheException { if (isModeGet) { return super.getWithLoader(key, null, null); } return super.get(key); }
ReadThroughCache extends EhcacheDecoratorAdapter { @Override public Element get(Object key) throws IllegalStateException, CacheException { if (isModeGet) { return super.getWithLoader(key, null, null); } return super.get(key); } }
ReadThroughCache extends EhcacheDecoratorAdapter { @Override public Element get(Object key) throws IllegalStateException, CacheException { if (isModeGet) { return super.getWithLoader(key, null, null); } return super.get(key); } ReadThroughCache(Ehcache underlyingCache, ReadThroughCacheConfiguration config); }
ReadThroughCache extends EhcacheDecoratorAdapter { @Override public Element get(Object key) throws IllegalStateException, CacheException { if (isModeGet) { return super.getWithLoader(key, null, null); } return super.get(key); } ReadThroughCache(Ehcache underlyingCache, ReadThroughCacheConfiguration config); @Override Element get(Object key); @Override Element get(Serializable key); @Override String getName(); }
ReadThroughCache extends EhcacheDecoratorAdapter { @Override public Element get(Object key) throws IllegalStateException, CacheException { if (isModeGet) { return super.getWithLoader(key, null, null); } return super.get(key); } ReadThroughCache(Ehcache underlyingCache, ReadThroughCacheConfiguration config); @Override Element get(Object key); @Override Element get(Serializable key); @Override String getName();  }