com.hazelcast.config
Class CacheConfig<K,V>

java.lang.Object
  extended by com.hazelcast.config.CacheConfig<K,V>
Type Parameters:
K - the key type
V - the value type
All Implemented Interfaces:
CacheConfiguration<K,V>, DataSerializable, Serializable, javax.cache.configuration.CompleteConfiguration<K,V>, javax.cache.configuration.Configuration<K,V>
Direct Known Subclasses:
CacheConfigReadOnly

public class CacheConfig<K,V>
extends Object

Contains all the configuration for the ICache

See Also:
Serialized Form

Field Summary
protected  javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<K,V>> cacheLoaderFactory
          The Factory for the CacheLoader.
protected  javax.cache.configuration.Factory<javax.cache.integration.CacheWriter<? super K,? super V>> cacheWriterFactory
          The Factory for the CacheWriter.
protected  javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy> expiryPolicyFactory
          The Factory for the ExpiryPolicy.
protected  boolean isManagementEnabled
          Whether management is enabled
protected  boolean isReadThrough
          A flag indicating if "read-through" mode is required.
protected  boolean isStatisticsEnabled
          A flag indicating if statistics gathering is enabled.
protected  boolean isStoreByValue
          A flag indicating if the cache will be store-by-value or store-by-reference.
protected  boolean isWriteThrough
          A flag indicating if "write-through" mode is required.
protected  Class<K> keyType
          The type of keys for Caches configured with this Configuration.
protected  Set<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>> listenerConfigurations
          The CacheEntryListenerConfigurations for the Configuration.
protected  Class<V> valueType
          The type of values for Caches configured with this Configuration.
 
Constructor Summary
CacheConfig()
           
CacheConfig(CacheSimpleConfig simpleConfig)
           
CacheConfig(javax.cache.configuration.CompleteConfiguration<K,V> configuration)
           
 
Method Summary
 CacheConfiguration<K,V> addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
          Add a configuration for a CacheEntryListener.
protected  Set<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>> createConcurrentSet()
           
 boolean equals(Object o)
           
 CacheConfigReadOnly<K,V> getAsReadOnly()
          Gets immutable version of this config.
 int getAsyncBackupCount()
          Gets the number of asynchronous backups of the cache config.
 int getBackupCount()
          Gets the number of synchronous backups of the cache config.
 Iterable<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>> getCacheEntryListenerConfigurations()
           
 javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<K,V>> getCacheLoaderFactory()
           
 javax.cache.configuration.Factory<javax.cache.integration.CacheWriter<? super K,? super V>> getCacheWriterFactory()
           
 CacheEvictionConfig getEvictionConfig()
          Gets the CacheEvictionConfig instance for eviction configuration of the cache config.
 javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy> getExpiryPolicyFactory()
           
 InMemoryFormat getInMemoryFormat()
          Gets the data type that will be used for storing records.
 Class<K> getKeyType()
           
 String getManagerPrefix()
          Gets the manager prefix of the cache config such as "hz://".
 String getName()
          Gets the name of the cache.
 String getNameWithPrefix()
          Gets the full name of cache with manager scope prefix.
 NearCacheConfig getNearCacheConfig()
          Gets the NearCacheConfig of the cache config instance.
 int getTotalBackupCount()
          Gets the total backup count (backupCount + asyncBackupCount) of the cache config.
 String getUriString()
          Gets the URI string which is global identifier of the cache.
 Class<V> getValueType()
           
 int hashCode()
           
 boolean isManagementEnabled()
           
 boolean isReadThrough()
           
 boolean isStatisticsEnabled()
           
 boolean isStoreByValue()
           
 boolean isWriteThrough()
           
 void readData(ObjectDataInput in)
          Reads fields from the input stream
 CacheConfiguration<K,V> removeCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
          Remove a configuration for a CacheEntryListener.
 CacheConfig<K,V> setAsyncBackupCount(int asyncBackupCount)
          Sets the number of asynchronous backups of cache config.
 CacheConfig<K,V> setBackupCount(int backupCount)
          Sets the number of synchronous backups.
 CacheConfiguration<K,V> setCacheLoaderFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K,V>> cacheLoaderFactory)
          Set the CacheLoader factory.
 CacheConfiguration<K,V> setCacheWriterFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<? super K,? super V>> cacheWriterFactory)
          Set the CacheWriter factory.
 CacheConfig setEvictionConfig(CacheEvictionConfig evictionConfig)
          Sets the CacheEvictionConfig instance for eviction configuration of the cache config.
 CacheConfiguration<K,V> setExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> expiryPolicyFactory)
          Set the Factory for the ExpiryPolicy.
 CacheConfig<K,V> setInMemoryFormat(InMemoryFormat inMemoryFormat)
          Data type that will be used for storing records.
 CacheConfiguration<K,V> setManagementEnabled(boolean enabled)
          Sets whether management is enabled on a cache.
 CacheConfig<K,V> setManagerPrefix(String managerPrefix)
          Sets the manager prefix of the cache config.
 CacheConfig<K,V> setName(String name)
          Sets the name of the cache.
 CacheConfig setNearCacheConfig(NearCacheConfig nearCacheConfig)
          Sets the NearCacheConfig of the cache config instance.
 CacheConfiguration<K,V> setReadThrough(boolean isReadThrough)
          Set if read-through caching should be used.
 CacheConfiguration<K,V> setStatisticsEnabled(boolean enabled)
          Sets whether statistics gathering is enabled on a cache.
 CacheConfiguration<K,V> setStoreByValue(boolean storeByValue)
          Set if a configured cache should use store-by-value or store-by-reference semantics.
 CacheConfiguration<K,V> setTypes(Class<K> keyType, Class<V> valueType)
          Sets the expected type of keys and values for a Cache configured with this Configuration.
 CacheConfig<K,V> setUriString(String uriString)
          Sets the URI string which is global identifier of the cache.
 CacheConfiguration<K,V> setWriteThrough(boolean isWriteThrough)
          Set if write-through caching should be used.
 String toString()
           
 void writeData(ObjectDataOutput out)
          Writes object fields to output stream
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

listenerConfigurations

protected Set<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>> listenerConfigurations
The CacheEntryListenerConfigurations for the Configuration.


keyType

protected Class<K> keyType
The type of keys for Caches configured with this Configuration.


valueType

protected Class<V> valueType
The type of values for Caches configured with this Configuration.


cacheLoaderFactory

protected javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<K,V>> cacheLoaderFactory
The Factory for the CacheLoader.


cacheWriterFactory

protected javax.cache.configuration.Factory<javax.cache.integration.CacheWriter<? super K,? super V>> cacheWriterFactory
The Factory for the CacheWriter.


expiryPolicyFactory

protected javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy> expiryPolicyFactory
The Factory for the ExpiryPolicy.


isReadThrough

protected boolean isReadThrough
A flag indicating if "read-through" mode is required.


isWriteThrough

protected boolean isWriteThrough
A flag indicating if "write-through" mode is required.


isStatisticsEnabled

protected boolean isStatisticsEnabled
A flag indicating if statistics gathering is enabled.


isStoreByValue

protected boolean isStoreByValue
A flag indicating if the cache will be store-by-value or store-by-reference.


isManagementEnabled

protected boolean isManagementEnabled
Whether management is enabled

Constructor Detail

CacheConfig

public CacheConfig()

CacheConfig

public CacheConfig(javax.cache.configuration.CompleteConfiguration<K,V> configuration)

CacheConfig

public CacheConfig(CacheSimpleConfig simpleConfig)
            throws Exception
Throws:
Exception
Method Detail

getAsReadOnly

public CacheConfigReadOnly<K,V> getAsReadOnly()
Gets immutable version of this config.

Returns:
Immutable version of this config

getName

public String getName()
Gets the name of the cache.

Returns:
the name of the cache

setName

public CacheConfig<K,V> setName(String name)
Sets the name of the cache.

Parameters:
name - the name of the cache to set
Returns:
current cache config instance

getManagerPrefix

public String getManagerPrefix()
Gets the manager prefix of the cache config such as "hz://".

Returns:
the manager prefix of this cache config

setManagerPrefix

public CacheConfig<K,V> setManagerPrefix(String managerPrefix)
Sets the manager prefix of the cache config.

Parameters:
managerPrefix - the manager prefix of the cache config to set
Returns:
current cache config instance

getUriString

public String getUriString()
Gets the URI string which is global identifier of the cache.

Returns:
the URI string of this cache config

setUriString

public CacheConfig<K,V> setUriString(String uriString)
Sets the URI string which is global identifier of the cache.

Parameters:
uriString - the URI string of the cache to set
Returns:
current cache config instance

getNameWithPrefix

public String getNameWithPrefix()
Gets the full name of cache with manager scope prefix.

Returns:
the name with manager scope prefix

getBackupCount

public int getBackupCount()
Gets the number of synchronous backups of the cache config.

Returns:
the backupCount the number of synchronous backups of the cache config
See Also:
getAsyncBackupCount()

setBackupCount

public CacheConfig<K,V> setBackupCount(int backupCount)
Sets the number of synchronous backups. If 1 is set as the backup-count for example, then all entries of the map will be copied to another JVM for fail-safety. 0 means no sync backup.

Parameters:
backupCount - the number of synchronous backups to set
Returns:
current cache config instance
See Also:
setAsyncBackupCount(int)

getAsyncBackupCount

public int getAsyncBackupCount()
Gets the number of asynchronous backups of the cache config.

Returns:
the number of asynchronous backups of the cache config
See Also:
setBackupCount(int)

setAsyncBackupCount

public CacheConfig<K,V> setAsyncBackupCount(int asyncBackupCount)
Sets the number of asynchronous backups of cache config. 0 means no backup.

Parameters:
asyncBackupCount - the number of asynchronous backups to set
Returns:
current cache config instance
See Also:
setBackupCount(int)

getTotalBackupCount

public int getTotalBackupCount()
Gets the total backup count (backupCount + asyncBackupCount) of the cache config.

Returns:
the total backup count (backupCount + asyncBackupCount) of the cache config

getEvictionConfig

public CacheEvictionConfig getEvictionConfig()
Gets the CacheEvictionConfig instance for eviction configuration of the cache config.

Returns:
the CacheEvictionConfig instance for eviction configuration

setEvictionConfig

public CacheConfig setEvictionConfig(CacheEvictionConfig evictionConfig)
Sets the CacheEvictionConfig instance for eviction configuration of the cache config.

Parameters:
evictionConfig - the CacheEvictionConfig instance for eviction configuration to set
Returns:
current cache config instance

getNearCacheConfig

public NearCacheConfig getNearCacheConfig()
Gets the NearCacheConfig of the cache config instance.

Returns:
the NearCacheConfig of the cache config instance

setNearCacheConfig

public CacheConfig setNearCacheConfig(NearCacheConfig nearCacheConfig)
Sets the NearCacheConfig of the cache config instance.

Parameters:
nearCacheConfig - the NearCacheConfig of the cache to set
Returns:
current cache config instance

getInMemoryFormat

public InMemoryFormat getInMemoryFormat()
Gets the data type that will be used for storing records.

Returns:
the data storage type of the cache config

setInMemoryFormat

public CacheConfig<K,V> setInMemoryFormat(InMemoryFormat inMemoryFormat)
Data type that will be used for storing records. Possible values: BINARY (default): keys and values will be stored as binary data OBJECT : values will be stored in their object forms

Parameters:
inMemoryFormat - the record type to set
Returns:
current cache config instance
Throws:
IllegalArgumentException - if inMemoryFormat is null.

writeData

public void writeData(ObjectDataOutput out)
               throws IOException
Description copied from interface: DataSerializable
Writes object fields to output stream

Parameters:
out - output
Throws:
IOException

readData

public void readData(ObjectDataInput in)
              throws IOException
Description copied from interface: DataSerializable
Reads fields from the input stream

Parameters:
in - input
Throws:
IOException

hashCode

public int hashCode()

equals

public boolean equals(Object o)

toString

public String toString()
Overrides:
toString in class Object

addCacheEntryListenerConfiguration

public CacheConfiguration<K,V> addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
Add a configuration for a CacheEntryListener.

Specified by:
addCacheEntryListenerConfiguration in interface CacheConfiguration<K,V>
Parameters:
cacheEntryListenerConfiguration - the CacheEntryListenerConfiguration
Returns:
the CacheConfig
Throws:
IllegalArgumentException - is the same CacheEntryListenerConfiguration is used more than once

removeCacheEntryListenerConfiguration

public CacheConfiguration<K,V> removeCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
Remove a configuration for a CacheEntryListener.

Specified by:
removeCacheEntryListenerConfiguration in interface CacheConfiguration<K,V>
Parameters:
cacheEntryListenerConfiguration - the CacheEntryListenerConfiguration to remove
Returns:
the CacheConfig

getCacheEntryListenerConfigurations

public Iterable<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>> getCacheEntryListenerConfigurations()
Specified by:
getCacheEntryListenerConfigurations in interface javax.cache.configuration.CompleteConfiguration<K,V>

isReadThrough

public boolean isReadThrough()
Specified by:
isReadThrough in interface javax.cache.configuration.CompleteConfiguration<K,V>

setReadThrough

public CacheConfiguration<K,V> setReadThrough(boolean isReadThrough)
Description copied from interface: CacheConfiguration
Set if read-through caching should be used.

It is an invalid configuration to set this to true without specifying a CacheLoader Factory.

Specified by:
setReadThrough in interface CacheConfiguration<K,V>
Parameters:
isReadThrough - true if read-through is required
Returns:
the CacheConfiguration to permit fluent-style method calls

isWriteThrough

public boolean isWriteThrough()
Specified by:
isWriteThrough in interface javax.cache.configuration.CompleteConfiguration<K,V>

setWriteThrough

public CacheConfiguration<K,V> setWriteThrough(boolean isWriteThrough)
Description copied from interface: CacheConfiguration
Set if write-through caching should be used.

It is an invalid configuration to set this to true without specifying a CacheWriter Factory.

Specified by:
setWriteThrough in interface CacheConfiguration<K,V>
Parameters:
isWriteThrough - true if write-through is required
Returns:
the CacheConfiguration to permit fluent-style method calls

isStatisticsEnabled

public boolean isStatisticsEnabled()
Specified by:
isStatisticsEnabled in interface javax.cache.configuration.CompleteConfiguration<K,V>

setStatisticsEnabled

public CacheConfiguration<K,V> setStatisticsEnabled(boolean enabled)
Sets whether statistics gathering is enabled on a cache.

Statistics may be enabled or disabled at runtime via CacheManager.enableStatistics(String, boolean).

Specified by:
setStatisticsEnabled in interface CacheConfiguration<K,V>
Parameters:
enabled - true to enable statistics, false to disable.
Returns:
the CacheConfig

isManagementEnabled

public boolean isManagementEnabled()
Specified by:
isManagementEnabled in interface javax.cache.configuration.CompleteConfiguration<K,V>

setManagementEnabled

public CacheConfiguration<K,V> setManagementEnabled(boolean enabled)
Sets whether management is enabled on a cache.

Management may be enabled or disabled at runtime via CacheManager.enableManagement(String, boolean).

Specified by:
setManagementEnabled in interface CacheConfiguration<K,V>
Parameters:
enabled - true to enable statistics, false to disable.
Returns:
the CacheConfig

getCacheLoaderFactory

public javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<K,V>> getCacheLoaderFactory()
Specified by:
getCacheLoaderFactory in interface javax.cache.configuration.CompleteConfiguration<K,V>

setCacheLoaderFactory

public CacheConfiguration<K,V> setCacheLoaderFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K,V>> cacheLoaderFactory)
Description copied from interface: CacheConfiguration
Set the CacheLoader factory.

Specified by:
setCacheLoaderFactory in interface CacheConfiguration<K,V>
Parameters:
cacheLoaderFactory - the CacheLoader Factory
Returns:
the CacheConfiguration to permit fluent-style method calls

setExpiryPolicyFactory

public CacheConfiguration<K,V> setExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> expiryPolicyFactory)
Description copied from interface: CacheConfiguration
Set the Factory for the ExpiryPolicy. If null is specified the default ExpiryPolicy is used.

Specified by:
setExpiryPolicyFactory in interface CacheConfiguration<K,V>
Parameters:
expiryPolicyFactory - the ExpiryPolicy Factory
Returns:
the CacheConfiguration to permit fluent-style method calls

setCacheWriterFactory

public CacheConfiguration<K,V> setCacheWriterFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<? super K,? super V>> cacheWriterFactory)
Description copied from interface: CacheConfiguration
Set the CacheWriter factory.

Specified by:
setCacheWriterFactory in interface CacheConfiguration<K,V>
Parameters:
cacheWriterFactory - the CacheWriter Factory
Returns:
the CacheConfiguration to permit fluent-style method calls

getCacheWriterFactory

public javax.cache.configuration.Factory<javax.cache.integration.CacheWriter<? super K,? super V>> getCacheWriterFactory()
Specified by:
getCacheWriterFactory in interface javax.cache.configuration.CompleteConfiguration<K,V>

getExpiryPolicyFactory

public javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy> getExpiryPolicyFactory()
Specified by:
getExpiryPolicyFactory in interface javax.cache.configuration.CompleteConfiguration<K,V>

getKeyType

public Class<K> getKeyType()
Specified by:
getKeyType in interface javax.cache.configuration.Configuration<K,V>

getValueType

public Class<V> getValueType()
Specified by:
getValueType in interface javax.cache.configuration.Configuration<K,V>

setTypes

public CacheConfiguration<K,V> setTypes(Class<K> keyType,
                                        Class<V> valueType)
Sets the expected type of keys and values for a Cache configured with this Configuration. Setting both to Object.class means type-safety checks are not required.

This is used by CacheManager to ensure that the key and value types are the same as those configured for the Cache prior to returning a requested cache from this method.

Implementations may further perform type checking on mutative cache operations and throw a ClassCastException if these checks fail.

Specified by:
setTypes in interface CacheConfiguration<K,V>
Parameters:
keyType - the expected key type
valueType - the expected value type
Returns:
the CacheConfig
Throws:
NullPointerException - should the key or value type be null
See Also:
CacheManager.getCache(String, Class, Class)

isStoreByValue

public boolean isStoreByValue()
Specified by:
isStoreByValue in interface javax.cache.configuration.Configuration<K,V>

setStoreByValue

public CacheConfiguration<K,V> setStoreByValue(boolean storeByValue)
Set if a configured cache should use store-by-value or store-by-reference semantics.

Specified by:
setStoreByValue in interface CacheConfiguration<K,V>
Parameters:
storeByValue - true if store-by-value is required, false for store-by-reference
Returns:
the CacheConfig

createConcurrentSet

protected Set<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>> createConcurrentSet()


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.