/** * Retrieves A COPY OF the default element attributes used by this region. This does not provide * a reference to the element attributes. * <p> * Each time an element is added to the cache without element attributes, the default element * attributes are cloned. * <p> * @return the default element attributes used by this region. * @throws CacheException */ @Override public IElementAttributes getDefaultElementAttributes() throws CacheException { return this.getCacheControl().getElementAttributes(); }
/** * Retrieves A COPY OF the default element attributes used by this region. This does not provide * a reference to the element attributes. * <p> * Each time an element is added to the cache without element attributes, the default element * attributes are cloned. * <p> * @return the default element attributes used by this region. * @throws CacheException */ @Override public IElementAttributes getDefaultElementAttributes() throws CacheException { return this.getCacheControl().getElementAttributes(); }
/** * GetElementAttributes will return an attribute object describing the current attributes * associated with the object name. The name object must override the Object.equals and * Object.hashCode methods. * <p> * @param name Key of object to get attributes for * @return Attributes for the object, null if object not in cache */ @Override public IElementAttributes getElementAttributes( K name ) { IElementAttributes attr = null; try { attr = this.getCacheControl().getElementAttributes( name ); } catch ( IOException ioe ) { log.error( "Failure getting element attributes", ioe ); } return attr; } }
/** * GetElementAttributes will return an attribute object describing the current attributes * associated with the object name. The name object must override the Object.equals and * Object.hashCode methods. * <p> * @param name Key of object to get attributes for * @return Attributes for the object, null if object not in cache */ @Override public IElementAttributes getElementAttributes( K name ) { IElementAttributes attr = null; try { attr = this.getCacheControl().getElementAttributes( name ); } catch ( IOException ioe ) { log.error( "Failure getting element attributes", ioe ); } return attr; } }
/** * Place a new object in the cache, associated with key name. If there is currently an object * associated with name in the region it is replaced. Names are scoped to a region so they must * be unique within the region they are placed. * @param name Key object will be stored with * @param obj Object to store */ @Override public void put( K name, V obj ) { // Call put with a copy of the contained caches default attributes. // the attributes are copied by the cacheControl put( name, obj, this.getCacheControl().getElementAttributes() ); }
/** * Place a new object in the cache, associated with key name. If there is currently an object * associated with name in the region it is replaced. Names are scoped to a region so they must * be unique within the region they are placed. * @param name Key object will be stored with * @param obj Object to store */ @Override public void put( K name, V obj ) { // Call put with a copy of the contained caches default attributes. // the attributes are copied by the cacheControl put( name, obj, this.getCacheControl().getElementAttributes() ); }
private ICacheElement<K, V> updateElement(final K key, final V v, final Duration duration) { final ICacheElement<K, V> element = new CacheElement<K, V>(name, key, v); final IElementAttributes copy = delegate.getElementAttributes().copy(); if (duration != null) { copy.setTimeFactorForMilliseconds(1); final boolean eternal = duration.isEternal(); copy.setIsEternal(eternal); if (!eternal) { copy.setIdleTime(duration.getTimeUnit().toMillis(duration.getDurationAmount())); } // MaxLife = -1 to use IdleTime excepted if jcache.ccf asked for something else } element.setElementAttributes(copy); return element; }
if (delegate.getElementAttributes() == null) delegate.getElementAttributes().addElementEventHandler(new EvictionListener(statistics));
new CacheElement<GroupAttrName<K>, V>( this.getCacheControl().getCacheName(), key, value ); IElementAttributes attributes = (attr == null) ? this.getCacheControl().getElementAttributes() : attr; ce.setElementAttributes( attributes );
new CacheElement<GroupAttrName<K>, V>( this.getCacheControl().getCacheName(), key, value ); IElementAttributes attributes = (attr == null) ? this.getCacheControl().getElementAttributes() : attr; ce.setElementAttributes( attributes );
/** * 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() ); }
ice.setElementAttributes( cache.getElementAttributes() ); lru.update( ice );
ice.setElementAttributes( cache.getElementAttributes() ); lru.update( ice );
ice.setElementAttributes( cache.getElementAttributes() ); lru.update( ice );
ice.setElementAttributes( cache.getElementAttributes() ); lru.update( ice );