Package org.wso2.carbon.caching.impl
Class CacheBuilderImpl<K,V>
- java.lang.Object
-
- org.wso2.carbon.caching.impl.CacheBuilderImpl<K,V>
-
- All Implemented Interfaces:
CacheBuilder<K,V>
public class CacheBuilderImpl<K,V> extends Object implements CacheBuilder<K,V>
TODO: class description
-
-
Constructor Summary
Constructors Constructor Description CacheBuilderImpl(String cacheName, CarbonCacheManager cacheManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Cache<K,V>build()Create an instance of the namedCache.CacheBuilder<K,V>registerCacheEntryListener(CacheEntryListener<K,V> cacheEntryListener)Registers a listener.CacheBuilder<K,V>setCacheLoader(CacheLoader<K,? extends V> cacheLoader)Sets the cache loader.CacheBuilder<K,V>setCacheWriter(CacheWriter<? super K,? super V> cacheWriter)Sets the cache writer.CacheBuilder<K,V>setExpiry(CacheConfiguration.ExpiryType type, CacheConfiguration.Duration duration)Sets the cache expirationCacheBuilder<K,V>setReadThrough(boolean readThrough)Sets whether the cache is a read-through cache.CacheBuilder<K,V>setStatisticsEnabled(boolean enableStatistics)Sets whether statistics gathering is enabled on this cache.CacheBuilder<K,V>setStoreByValue(boolean storeByValue)Sets whether the cache is store-by-value cache.CacheBuilder<K,V>setTransactionEnabled(IsolationLevel isolationLevel, Mode mode)Sets whether transaction are enabled for this cache.CacheBuilder<K,V>setWriteThrough(boolean writeThrough)Whether the cache is a write-through cache.
-
-
-
Constructor Detail
-
CacheBuilderImpl
public CacheBuilderImpl(String cacheName, CarbonCacheManager cacheManager)
-
-
Method Detail
-
build
public Cache<K,V> build()
Description copied from interface:CacheBuilderCreate an instance of the namedCache. The Cache will be created, added to the caches controlled by its associated CacheManager and started. If there is an existing Cache of the same name associated with this CacheManager when build is invoked, the old Cache will be stopped.- Specified by:
buildin interfaceCacheBuilder<K,V>- Returns:
- a new instance of the named cache
- See Also:
CacheManager.createCacheBuilder(String)
-
setCacheLoader
public CacheBuilder<K,V> setCacheLoader(CacheLoader<K,? extends V> cacheLoader)
Description copied from interface:CacheBuilderSets the cache loader.- Specified by:
setCacheLoaderin interfaceCacheBuilder<K,V>- Parameters:
cacheLoader- the CacheLoader- Returns:
- the builder
-
setCacheWriter
public CacheBuilder<K,V> setCacheWriter(CacheWriter<? super K,? super V> cacheWriter)
Description copied from interface:CacheBuilderSets the cache writer.- Specified by:
setCacheWriterin interfaceCacheBuilder<K,V>- Parameters:
cacheWriter- the CacheWriter- Returns:
- the builder
-
registerCacheEntryListener
public CacheBuilder<K,V> registerCacheEntryListener(CacheEntryListener<K,V> cacheEntryListener)
Description copied from interface:CacheBuilderRegisters a listener. Can be invoked multiple times.- Specified by:
registerCacheEntryListenerin interfaceCacheBuilder<K,V>- Parameters:
cacheEntryListener- the listener- Returns:
- the builder
-
setStoreByValue
public CacheBuilder<K,V> setStoreByValue(boolean storeByValue)
Description copied from interface:CacheBuilderSets whether the cache is store-by-value cache.- Specified by:
setStoreByValuein interfaceCacheBuilder<K,V>- Parameters:
storeByValue- the value for storeByValue- Returns:
- the builder
- See Also:
CacheConfiguration.isStoreByValue()
-
setTransactionEnabled
public CacheBuilder<K,V> setTransactionEnabled(IsolationLevel isolationLevel, Mode mode)
Description copied from interface:CacheBuilderSets whether transaction are enabled for this cache.- Specified by:
setTransactionEnabledin interfaceCacheBuilder<K,V>- Parameters:
isolationLevel- - the isolation level for this cachemode- - the mode (Local or XA) for this cache- Returns:
- the builder
- See Also:
CacheConfiguration.isTransactionEnabled()
-
setStatisticsEnabled
public CacheBuilder<K,V> setStatisticsEnabled(boolean enableStatistics)
Description copied from interface:CacheBuilderSets whether statistics gathering is enabled on this cache.- Specified by:
setStatisticsEnabledin interfaceCacheBuilder<K,V>- Parameters:
enableStatistics- true to enable statistics, false to disable- Returns:
- the builder
- See Also:
CacheConfiguration.setStatisticsEnabled(boolean)
-
setReadThrough
public CacheBuilder<K,V> setReadThrough(boolean readThrough)
Description copied from interface:CacheBuilderSets whether the cache is a read-through cache. If so a CacheLoader should be configured.- Specified by:
setReadThroughin interfaceCacheBuilder<K,V>- Parameters:
readThrough- the value for readThrough- Returns:
- the builder
-
setWriteThrough
public CacheBuilder<K,V> setWriteThrough(boolean writeThrough)
Description copied from interface:CacheBuilderWhether the cache is a write-through cache. A CacheWriter should be configured.- Specified by:
setWriteThroughin interfaceCacheBuilder<K,V>- Parameters:
writeThrough- set to true for a write-through cache- Returns:
- the builder
-
setExpiry
public CacheBuilder<K,V> setExpiry(CacheConfiguration.ExpiryType type, CacheConfiguration.Duration duration)
Description copied from interface:CacheBuilderSets the cache expiration- Specified by:
setExpiryin interfaceCacheBuilder<K,V>- Parameters:
type- whether based on creation/modification or last access timeduration- the amount of time- Returns:
- the builder
-
-