public class CacheBuilderImpl<K,V> extends Object implements CacheBuilder<K,V>
Constructor and Description |
---|
CacheBuilderImpl(String cacheName,
CarbonCacheManager cacheManager) |
Modifier and Type | Method and Description |
---|---|
Cache<K,V> |
build()
Create an instance of the named
Cache . |
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 expiration
|
CacheBuilder<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.
|
public CacheBuilderImpl(String cacheName, CarbonCacheManager cacheManager)
public Cache<K,V> build()
CacheBuilder
Cache
.
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.build
in interface CacheBuilder<K,V>
CacheManager.createCacheBuilder(String)
public CacheBuilder<K,V> setCacheLoader(CacheLoader<K,? extends V> cacheLoader)
CacheBuilder
setCacheLoader
in interface CacheBuilder<K,V>
cacheLoader
- the CacheLoaderpublic CacheBuilder<K,V> setCacheWriter(CacheWriter<? super K,? super V> cacheWriter)
CacheBuilder
setCacheWriter
in interface CacheBuilder<K,V>
cacheWriter
- the CacheWriterpublic CacheBuilder<K,V> registerCacheEntryListener(CacheEntryListener<K,V> cacheEntryListener)
CacheBuilder
registerCacheEntryListener
in interface CacheBuilder<K,V>
cacheEntryListener
- the listenerpublic CacheBuilder<K,V> setStoreByValue(boolean storeByValue)
CacheBuilder
setStoreByValue
in interface CacheBuilder<K,V>
storeByValue
- the value for storeByValueCacheConfiguration.isStoreByValue()
public CacheBuilder<K,V> setTransactionEnabled(IsolationLevel isolationLevel, Mode mode)
CacheBuilder
setTransactionEnabled
in interface CacheBuilder<K,V>
isolationLevel
- - the isolation level for this cachemode
- - the mode (Local or XA) for this cacheCacheConfiguration.isTransactionEnabled()
public CacheBuilder<K,V> setStatisticsEnabled(boolean enableStatistics)
CacheBuilder
setStatisticsEnabled
in interface CacheBuilder<K,V>
enableStatistics
- true to enable statistics, false to disableCacheConfiguration.setStatisticsEnabled(boolean)
public CacheBuilder<K,V> setReadThrough(boolean readThrough)
CacheBuilder
setReadThrough
in interface CacheBuilder<K,V>
readThrough
- the value for readThroughpublic CacheBuilder<K,V> setWriteThrough(boolean writeThrough)
CacheBuilder
setWriteThrough
in interface CacheBuilder<K,V>
writeThrough
- set to true for a write-through cachepublic CacheBuilder<K,V> setExpiry(CacheConfiguration.ExpiryType type, CacheConfiguration.Duration duration)
CacheBuilder
setExpiry
in interface CacheBuilder<K,V>
type
- whether based on creation/modification or last access timeduration
- the amount of timeCopyright © 2015 WSO2 Inc. All rights reserved.