Package com.hazelcast.config
Class CacheConfig<K,V>
java.lang.Object
com.hazelcast.config.AbstractCacheConfig<K,V>
com.hazelcast.config.CacheConfig<K,V>
- Type Parameters:
K- the key typeV- the value type
- All Implemented Interfaces:
CacheConfiguration<K,,V> UserCodeNamespaceAwareConfig<CacheConfig<K,,V>> DataSerializable,IdentifiedDataSerializable,com.hazelcast.nio.serialization.impl.Versioned,Serializable,javax.cache.configuration.CompleteConfiguration<K,,V> javax.cache.configuration.Configuration<K,V>
public class CacheConfig<K,V>
extends AbstractCacheConfig<K,V>
implements com.hazelcast.nio.serialization.impl.Versioned, UserCodeNamespaceAwareConfig<CacheConfig<K,V>>
Contains all the configuration for the
ICache.- See Also:
-
Field Summary
Fields inherited from class com.hazelcast.config.AbstractCacheConfig
cacheLoaderFactory, cacheWriterFactory, classLoader, dataPersistenceConfig, eventJournalConfig, expiryPolicyFactory, hotRestartConfig, isManagementEnabled, isReadThrough, isStatisticsEnabled, isStoreByValue, isWriteThrough, listenerConfigurations, serializationServiceFields inherited from interface com.hazelcast.config.UserCodeNamespaceAwareConfig
DEFAULT_NAMESPACE -
Constructor Summary
ConstructorsConstructorDescriptionCacheConfig(CacheSimpleConfig simpleConfig) CacheConfig(String name) CacheConfig(javax.cache.configuration.CompleteConfiguration<K, V> configuration) -
Method Summary
Modifier and TypeMethodDescription<T extends CacheConfig<K,V>>
Tcopy(T target, boolean resolved) Copy this CacheConfig to giventargetobject whose type extends CacheConfig.booleanintGets the number of asynchronous backups for thisICache.intGets the number of synchronous backups for thisICache.intReturns type identifier for this class.Gets theEvictionConfiginstance of the eviction configuration for thisICache.Gets the data type that will be used to store records.Gets the manager prefix of theICache, such as "hz://".Gets theMergePolicyConfigfor this map.Gets theMerkleTreeConfigfor thisCacheConfiggetName()Gets the name of thisICache.Gets the full name of theICache, including the manager scope prefix.Gets the partition lost listener references added to cache configuration.Gets the name of the associated split brain protection if any.intGets the total backup count (backupCount + asyncBackupCount) of the cache.Gets the URI string which is the global identifier for thisICache.Retrieve the User Code Deployment Namespace to be used forClassLoaderawareness during operations related to the structure associated with this configuration.inthashCode()booleanReturns invalidation events disabled status for per entry.voidReads fields from the input streamprotected voidprotected voidprotected voidprotected voidsetAsyncBackupCount(int asyncBackupCount) Sets the number of asynchronous backups for thisICache.setBackupCount(int backupCount) Sets the number of synchronous backups.setDisablePerEntryInvalidationEvents(boolean disablePerEntryInvalidationEvents) Sets invalidation events disabled status for per entry.setEvictionConfig(EvictionConfig evictionConfig) Sets theEvictionConfiginstance for eviction configuration for thisICache.setInMemoryFormat(InMemoryFormat inMemoryFormat) Data type that will be used to store records in thisICache.setManagerPrefix(String managerPrefix) Sets the manager prefix of theICache.setMergePolicyConfig(MergePolicyConfig mergePolicyConfig) Sets theMergePolicyConfigfor this map.voidsetMerkleTreeConfig(MerkleTreeConfig merkleTreeConfig) Sets theMerkleTreeConfigfor thisCacheConfigSets the name of thisICache.setPartitionLostListenerConfigs(List<CachePartitionLostListenerConfig> partitionLostListenerConfigs) Sets the WAN target replication reference.setSplitBrainProtectionName(String splitBrainProtectionName) Associates this cache configuration to a split brain protection.setUriString(String uriString) Sets the URI string, which is the global identifier of theICache.setUserCodeNamespace(String userCodeNamespace) Associates the provided Namespace Name with this structure forClassLoaderawareness.setWanReplicationRef(WanReplicationRef wanReplicationRef) toString()voidWrites object fields to output streamprotected voidprotected voidprotected voidprotected voidMethods inherited from class com.hazelcast.config.AbstractCacheConfig
addCacheEntryListenerConfiguration, createConcurrentSet, getCacheEntryListenerConfigurations, getCacheLoaderFactory, getCacheWriterFactory, getDataPersistenceConfig, getEventJournalConfig, getExpiryPolicyFactory, getFactoryId, getHotRestartConfig, getKeyClassName, getKeyType, getListenerConfigurations, getValueClassName, getValueType, hasListenerConfiguration, isManagementEnabled, isReadThrough, isStatisticsEnabled, isStoreByValue, isWriteThrough, keyValueTypesEqual, removeCacheEntryListenerConfiguration, setCacheLoaderFactory, setCacheWriterFactory, setClassLoader, setDataPersistenceConfig, setEventJournalConfig, setExpiryPolicyFactory, setHotRestartConfig, setKeyClassName, setKeyType, setListenerConfigurations, setListenerConfigurations, setManagementEnabled, setReadThrough, setStatisticsEnabled, setStoreByValue, setTypes, setValueClassName, setValueType, setWriteThrough
-
Constructor Details
-
CacheConfig
public CacheConfig() -
CacheConfig
-
CacheConfig
-
CacheConfig
- Throws:
Exception
-
-
Method Details
-
getName
Gets the name of thisICache.- Returns:
- the name of this
ICache
-
setName
Sets the name of thisICache.- Parameters:
name- the name to set for thisICache- Returns:
- the current cache config instance
-
getManagerPrefix
Gets the manager prefix of theICache, such as "hz://".- Returns:
- the manager prefix of this
ICache
-
setManagerPrefix
Sets the manager prefix of theICache.- Parameters:
managerPrefix- the manager prefix to set for thisICache- Returns:
- the current cache config instance
-
getUriString
Gets the URI string which is the global identifier for thisICache.- Returns:
- the URI string of this
ICache
-
setUriString
Sets the URI string, which is the global identifier of theICache.- Parameters:
uriString- the URI string to set for thisICache- Returns:
- the current cache config instance
-
getNameWithPrefix
Gets the full name of theICache, including the manager scope prefix.- Returns:
- the full name of the
ICache, including the manager scope prefix
-
getBackupCount
public int getBackupCount()Gets the number of synchronous backups for thisICache.- Returns:
- the number of synchronous backups (backupCount) for this
ICache - See Also:
-
setBackupCount
Sets the number of synchronous backups. For example, if 1 is set as the backup count, then all entries of the map will be copied to another JVM for fail-safety. 0 means no synchronous backup.- Parameters:
backupCount- the number of synchronous backups to set for thisICache- Returns:
- the current cache config instance
- Throws:
IllegalArgumentException- if backupCount smaller than 0, or larger than the maximum number of backup, or the sum of the synchronous and asynchronous backups is larger than the maximum number of backups- See Also:
-
getAsyncBackupCount
public int getAsyncBackupCount()Gets the number of asynchronous backups for thisICache.- Returns:
- the number of asynchronous backups for this
ICache - See Also:
-
setAsyncBackupCount
Sets the number of asynchronous backups for thisICache.- Parameters:
asyncBackupCount- the number of asynchronous backups to set for thisICache- Returns:
- the updated CacheConfig
- Throws:
IllegalArgumentException- if asyncBackupCount is smaller than 0, or larger than the maximum number of backups, or the sum of the synchronous and asynchronous backups is larger than the maximum number of backups- See Also:
-
getTotalBackupCount
public int getTotalBackupCount()Gets the total backup count (backupCount + asyncBackupCount) of the cache.- Returns:
- the total backup count (
backupCount + asyncBackupCount) of the cache
-
getEvictionConfig
Gets theEvictionConfiginstance of the eviction configuration for thisICache.- Returns:
- the
EvictionConfiginstance of the eviction configuration
-
setEvictionConfig
Sets theEvictionConfiginstance for eviction configuration for thisICache.- Parameters:
evictionConfig- theEvictionConfiginstance to set for the eviction configuration- Returns:
- the current cache config instance
-
getWanReplicationRef
-
setWanReplicationRef
-
getPartitionLostListenerConfigs
Gets the partition lost listener references added to cache configuration.- Returns:
- List of CachePartitionLostListenerConfig
-
setPartitionLostListenerConfigs
public CacheConfig<K,V> setPartitionLostListenerConfigs(List<CachePartitionLostListenerConfig> partitionLostListenerConfigs) Sets the WAN target replication reference.- Parameters:
partitionLostListenerConfigs- CachePartitionLostListenerConfig list
-
getInMemoryFormat
Gets the data type that will be used to store records.- Returns:
- the data storage type of the cache config
-
setInMemoryFormat
Data type that will be used to store records in thisICache. Possible values:- BINARY (default): keys and values will be stored as binary data
- OBJECT: values will be stored in their object forms
- NATIVE: values will be stored in non-heap region of JVM (Hazelcast Enterprise only)
- Parameters:
inMemoryFormat- the record type to set- Returns:
- current cache config instance
- Throws:
IllegalArgumentException- if inMemoryFormat isnull
-
getSplitBrainProtectionName
Gets the name of the associated split brain protection if any.- Returns:
- the name of the associated split brain protection if any
-
setSplitBrainProtectionName
Associates this cache configuration to a split brain protection.- Parameters:
splitBrainProtectionName- name of the desired split brain protection- Returns:
- the updated CacheConfig
-
getMergePolicyConfig
Gets theMergePolicyConfigfor this map.- Returns:
- the
MergePolicyConfigfor this map
-
setMergePolicyConfig
Sets theMergePolicyConfigfor this map.- Returns:
- the updated map configuration
-
getMerkleTreeConfig
Gets theMerkleTreeConfigfor thisCacheConfig- Returns:
- merkle tree config
-
setMerkleTreeConfig
Sets theMerkleTreeConfigfor thisCacheConfig- Parameters:
merkleTreeConfig- merkle tree config
-
isDisablePerEntryInvalidationEvents
public boolean isDisablePerEntryInvalidationEvents()Returns invalidation events disabled status for per entry.- Returns:
trueif invalidation events are disabled for per entry,falseotherwise
-
setDisablePerEntryInvalidationEvents
public CacheConfig<K,V> setDisablePerEntryInvalidationEvents(boolean disablePerEntryInvalidationEvents) Sets invalidation events disabled status for per entry.- Parameters:
disablePerEntryInvalidationEvents- disables invalidation event sending behaviour if it istrue, otherwise enables it- Returns:
- this configuration
-
getUserCodeNamespace
Retrieve the User Code Deployment Namespace to be used forClassLoaderawareness during operations related to the structure associated with this configuration.- Specified by:
getUserCodeNamespacein interfaceUserCodeNamespaceAwareConfig<K>- Returns:
- Namespace Name for use with the
UserCodeNamespaceService, ornullif there is no User Code Namespace to associate with.
-
setUserCodeNamespace
Associates the provided Namespace Name with this structure forClassLoaderawareness.The behaviour of setting this to
nullis outlined in the documentation forUserCodeNamespaceAwareConfig.DEFAULT_NAMESPACE.- Specified by:
setUserCodeNamespacein interfaceUserCodeNamespaceAwareConfig<K>- Parameters:
userCodeNamespace- The ID of the Namespace to associate with this structure.- Returns:
- the updated
ExecutorConfiginstance - Since:
- 5.4
-
writeData
Description copied from interface:DataSerializableWrites object fields to output stream- Specified by:
writeDatain interfaceDataSerializable- Parameters:
out- output- Throws:
IOException- if an I/O error occurs. In particular, anIOExceptionmay be thrown if the output stream has been closed.
-
getClassId
public int getClassId()Description copied from interface:IdentifiedDataSerializableReturns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassIdin interfaceIdentifiedDataSerializable- Returns:
- type ID
-
readData
Description copied from interface:DataSerializableReads fields from the input stream- Specified by:
readDatain interfaceDataSerializable- Parameters:
in- input- Throws:
IOException- if an I/O error occurs. In particular, anIOExceptionmay be thrown if the input stream has been closed.
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractCacheConfig<K,V>
-
equals
- Overrides:
equalsin classAbstractCacheConfig<K,V>
-
toString
-
writeTenant
-
readTenant
-
writeKeyValueTypes
- Throws:
IOException
-
readKeyValueTypes
- Throws:
IOException
-
writeFactories
- Throws:
IOException
-
readFactories
- Throws:
IOException
-
writeListenerConfigurations
- Throws:
IOException
-
readListenerConfigurations
- Throws:
IOException
-
copy
Copy this CacheConfig to giventargetobject whose type extends CacheConfig.- Type Parameters:
T- the target object type- Parameters:
target- the target object to which this configuration will be copiedresolved- whentrue, it is assumed that thiscacheConfig's key-value types have already been or will be resolved to loaded classes and the actualkeyTypeandvalueTypewill be copied. Otherwise, this configuration'skeyClassNameandvalueClassNamewill be copied to the target config, to be resolved at a later time.- Returns:
- the target config
-