K
- the key typeV
- the value typepublic interface CacheBuilder<K,V>
CacheManager.createCacheBuilder(String)
and is associated with that
manager.
Additional configuration methods may be available on a builder instance by casting to a concrete implementation.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.
|
Cache<K,V> build()
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.InvalidConfigurationException
- thrown if the configuration is invalid. Examples include if
read through has been set to true but no cache loader is specified, or if no cache writer is specified but
write through has been set.CacheException
- if a cache with that name already exists or there was an error adding the cache to the CacheManagerCacheManager.createCacheBuilder(String)
CacheBuilder<K,V> setCacheLoader(CacheLoader<K,? extends V> cacheLoader)
cacheLoader
- the CacheLoaderNullPointerException
- if cacheLoader is null.CacheBuilder<K,V> setCacheWriter(CacheWriter<? super K,? super V> cacheWriter)
cacheWriter
- the CacheWriterNullPointerException
- if cacheWriter is null.CacheBuilder<K,V> registerCacheEntryListener(CacheEntryListener<K,V> cacheEntryListener)
cacheEntryListener
- the listenerNullPointerException
- if any of the arguments are null.CacheBuilder<K,V> setStoreByValue(boolean storeByValue)
storeByValue
- the value for storeByValueIllegalStateException
- if the configuration can no longer be changedInvalidConfigurationException
- if the cache does not support store by referenceCacheConfiguration.isStoreByValue()
CacheBuilder<K,V> setTransactionEnabled(IsolationLevel isolationLevel, Mode mode)
isolationLevel
- - the isolation level for this cachemode
- - the mode (Local or XA) for this cacheIllegalArgumentException
- if the cache does not support transactions,
or an attempt is made to set the isolation level to IsolationLevel.NONE
or the mode to Mode.NONE
.CacheConfiguration.isTransactionEnabled()
CacheBuilder<K,V> setStatisticsEnabled(boolean enableStatistics)
enableStatistics
- true to enable statistics, false to disableCacheConfiguration.setStatisticsEnabled(boolean)
CacheBuilder<K,V> setReadThrough(boolean readThrough)
readThrough
- the value for readThroughCacheBuilder<K,V> setWriteThrough(boolean writeThrough)
writeThrough
- set to true for a write-through cacheCacheBuilder<K,V> setExpiry(CacheConfiguration.ExpiryType type, CacheConfiguration.Duration duration)
type
- whether based on creation/modification or last access timeduration
- the amount of timeNullPointerException
- if size is durationCopyright © 2015 WSO2 Inc. All rights reserved.