/** * Gets the ICompositeCacheAttributes of the cache region. * <p> * @return ICompositeCacheAttributes, the controllers config info, defined in the top section of * a region definition. */ @Override public ICompositeCacheAttributes getCacheAttributes() { return this.getCacheControl().getCacheAttributes(); }
/** * Gets the ICompositeCacheAttributes of the cache region. * <p> * @return ICompositeCacheAttributes, the controllers config info, defined in the top section of * a region definition. */ @Override public ICompositeCacheAttributes getCacheAttributes() { return this.getCacheControl().getCacheAttributes(); }
public JcsCache(final CompositeCache cache) throws CacheException { this(cache.getCacheName(), cache.getCacheAttributes()); }
/** * For post reflection creation initialization * <p> * @param hub */ @Override public void initialize( CompositeCache<K, V> hub ) { hitCnt = new AtomicLong(0); missCnt = new AtomicLong(0); putCnt = new AtomicLong(0); this.cacheAttributes = hub.getCacheAttributes(); this.chunkSize = cacheAttributes.getSpoolChunkSize(); this.cache = hub; this.map = createMap(); this.status = CacheStatus.ALIVE; }
/** * Constructor for the ShrinkerThread object. * <p> * @param cache The MemoryCache which the new shrinker should watch. */ public ShrinkerThread( CompositeCache<K, V> cache ) { super(); this.cache = cache; long maxMemoryIdleTimeSeconds = cache.getCacheAttributes().getMaxMemoryIdleTimeSeconds(); if ( maxMemoryIdleTimeSeconds < 0 ) { this.maxMemoryIdleTime = -1; } else { this.maxMemoryIdleTime = maxMemoryIdleTimeSeconds * 1000; } this.maxSpoolPerRun = cache.getCacheAttributes().getMaxSpoolPerRun(); if ( this.maxSpoolPerRun != -1 ) { this.spoolLimit = true; } }
/** * Constructor for the ShrinkerThread object. * <p> * @param cache The MemoryCache which the new shrinker should watch. */ public ShrinkerThread( CompositeCache<K, V> cache ) { super(); this.cache = cache; long maxMemoryIdleTimeSeconds = cache.getCacheAttributes().getMaxMemoryIdleTimeSeconds(); if ( maxMemoryIdleTimeSeconds < 0 ) { this.maxMemoryIdleTime = -1; } else { this.maxMemoryIdleTime = maxMemoryIdleTimeSeconds * 1000; } this.maxSpoolPerRun = cache.getCacheAttributes().getMaxSpoolPerRun(); if ( this.maxSpoolPerRun != -1 ) { this.spoolLimit = true; } }
/** * For post reflection creation initialization * <p> * @param hub */ @Override public void initialize( CompositeCache<K, V> hub ) { lock.lock(); try { this.cacheName = hub.getCacheName(); this.cacheAttributes = hub.getCacheAttributes(); this.cache = hub; map = createMap(); chunkSize = cacheAttributes.getSpoolChunkSize(); status = CacheStatus.ALIVE; } finally { lock.unlock(); } }
/** * Verify that we can parse the spool chunk size */ public void testParseSpoolChunkSize_Normal() { // SETUP String regionName = "MyRegion"; int chunkSize = 5; Properties props = new Properties(); props.put( "jcs.default", "" ); props.put( "jcs.default.cacheattributes.SpoolChunkSize", String.valueOf( chunkSize ) ); CompositeCacheManager manager = CompositeCacheManager.getUnconfiguredInstance(); // DO WORK manager.configure( props ); // VERIFY CompositeCache<String, String> cache = manager.getCache( regionName ); assertEquals( "Wrong chunkSize", cache.getCacheAttributes().getSpoolChunkSize(), chunkSize ); } }
/** * Verify that we can parse the spool chunk size */ public void testParseSpoolChunkSize_Normal() { // SETUP String regionName = "MyRegion"; int chunkSize = 5; Properties props = new Properties(); props.put( "jcs.default", "" ); props.put( "jcs.default.cacheattributes.SpoolChunkSize", String.valueOf( chunkSize ) ); CompositeCacheManager manager = CompositeCacheManager.getUnconfiguredInstance(); // DO WORK manager.configure( props ); // VERIFY CompositeCache<String, String> cache = manager.getCache( regionName ); assertEquals( "Wrong chunkSize", cache.getCacheAttributes().getSpoolChunkSize(), chunkSize ); } }
/** * Put half the max and clear. get the key array and verify that it has the correct number of * items. * <p> * @throws Exception */ public void testGetKeyArray() throws Exception { CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( "/TestSoftReferenceCache.ccf" ); CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" ); SoftReferenceMemoryCache<String, String> srmc = new SoftReferenceMemoryCache<String, String>(); srmc.initialize( cache ); int max = cache.getCacheAttributes().getMaxObjects(); int items = max / 2; for ( int i = 0; i < items; i++ ) { ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i ); ice.setElementAttributes( cache.getElementAttributes() ); srmc.update( ice ); } Set<String> keys = srmc.getKeySet(); assertEquals( "Wrong number of keys.", items, keys.size() ); }
/** * Put half the max and clear. get the key array and verify that it has the correct number of * items. * <p> * @throws Exception */ public void testGetKeyArray() throws Exception { CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( "/TestLHMLRUCache.ccf" ); CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" ); LHMLRUMemoryCache<String, String> mru = new LHMLRUMemoryCache<String, String>(); mru.initialize( cache ); int max = cache.getCacheAttributes().getMaxObjects(); int items = max / 2; for ( int i = 0; i < items; i++ ) { ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i ); ice.setElementAttributes( cache.getElementAttributes() ); mru.update( ice ); } Set<String> keys = mru.getKeySet(); assertEquals( "Wrong number of keys.", items, keys.size() ); }
/** * Put half the max and clear. get the key array and verify that it has the correct number of * items. * <p> * @throws Exception */ public void testGetKeyArray() throws Exception { CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( "/TestMRUCache.ccf" ); CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" ); MRUMemoryCache<String, String> mru = new MRUMemoryCache<String, String>(); mru.initialize( cache ); int max = cache.getCacheAttributes().getMaxObjects(); int items = max / 2; for ( int i = 0; i < items; i++ ) { ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i ); ice.setElementAttributes( cache.getElementAttributes() ); mru.update( ice ); } Set<String> keys = mru.getKeySet(); assertEquals( "Wrong number of keys.", items, keys.size() ); }
/** * Put half the max and clear. get the key array and verify that it has the correct number of * items. * <p> * @throws Exception */ public void testGetKeyArray() throws Exception { CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( "/TestLHMLRUCache.ccf" ); CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" ); LHMLRUMemoryCache<String, String> mru = new LHMLRUMemoryCache<String, String>(); mru.initialize( cache ); int max = cache.getCacheAttributes().getMaxObjects(); int items = max / 2; for ( int i = 0; i < items; i++ ) { ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i ); ice.setElementAttributes( cache.getElementAttributes() ); mru.update( ice ); } Set<String> keys = mru.getKeySet(); assertEquals( "Wrong number of keys.", items, keys.size() ); }
/** * Put half the max and clear. get the key array and verify that it has the correct number of * items. * <p> * @throws Exception */ public void testGetKeyArray() throws Exception { CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( "/TestMRUCache.ccf" ); CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" ); MRUMemoryCache<String, String> mru = new MRUMemoryCache<String, String>(); mru.initialize( cache ); int max = cache.getCacheAttributes().getMaxObjects(); int items = max / 2; for ( int i = 0; i < items; i++ ) { ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i ); ice.setElementAttributes( cache.getElementAttributes() ); mru.update( ice ); } Set<String> keys = mru.getKeySet(); assertEquals( "Wrong number of keys.", items, keys.size() ); }