org.wso2.carbon.caching.impl
Class CacheBuilderImpl<K,V>

java.lang.Object
  extended by 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
CacheBuilderImpl(String cacheName, CarbonCacheManager cacheManager)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheBuilderImpl

public CacheBuilderImpl(String cacheName,
                        CarbonCacheManager cacheManager)
Method Detail

build

public Cache<K,V> build()
Description copied from interface: CacheBuilder
Create an instance of the named 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.

Specified by:
build in interface CacheBuilder<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: CacheBuilder
Sets the cache loader.

Specified by:
setCacheLoader in interface CacheBuilder<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: CacheBuilder
Sets the cache writer.

Specified by:
setCacheWriter in interface CacheBuilder<K,V>
Parameters:
cacheWriter - the CacheWriter
Returns:
the builder

registerCacheEntryListener

public CacheBuilder<K,V> registerCacheEntryListener(CacheEntryListener<K,V> cacheEntryListener)
Description copied from interface: CacheBuilder
Registers a listener. Can be invoked multiple times.

Specified by:
registerCacheEntryListener in interface CacheBuilder<K,V>
Parameters:
cacheEntryListener - the listener
Returns:
the builder

setStoreByValue

public CacheBuilder<K,V> setStoreByValue(boolean storeByValue)
Description copied from interface: CacheBuilder
Sets whether the cache is store-by-value cache.

Specified by:
setStoreByValue in interface CacheBuilder<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: CacheBuilder
Sets whether transaction are enabled for this cache.

Specified by:
setTransactionEnabled in interface CacheBuilder<K,V>
Parameters:
isolationLevel - - the isolation level for this cache
mode - - 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: CacheBuilder
Sets whether statistics gathering is enabled on this cache.

Specified by:
setStatisticsEnabled in interface CacheBuilder<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: CacheBuilder
Sets whether the cache is a read-through cache. If so a CacheLoader should be configured.

Specified by:
setReadThrough in interface CacheBuilder<K,V>
Parameters:
readThrough - the value for readThrough
Returns:
the builder

setWriteThrough

public CacheBuilder<K,V> setWriteThrough(boolean writeThrough)
Description copied from interface: CacheBuilder
Whether the cache is a write-through cache. A CacheWriter should be configured.

Specified by:
setWriteThrough in interface CacheBuilder<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: CacheBuilder
Sets the cache expiration

Specified by:
setExpiry in interface CacheBuilder<K,V>
Parameters:
type - whether based on creation/modification or last access time
duration - the amount of time
Returns:
the builder


Copyright © 2014 WSO2 Inc. All rights reserved.