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, serializationService
Fields inherited from interface com.hazelcast.config.UserCodeNamespaceAwareConfig
DEFAULT_NAMESPACE
-
Constructor Summary
ConstructorDescriptionCacheConfig
(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 giventarget
object whose type extends CacheConfig.boolean
int
Gets the number of asynchronous backups for thisICache
.int
Gets the number of synchronous backups for thisICache
.int
Returns type identifier for this class.Gets theEvictionConfig
instance 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 theMergePolicyConfig
for this map.Gets theMerkleTreeConfig
for thisCacheConfig
getName()
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.int
Gets 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 forClassLoader
awareness during operations related to the structure associated with this configuration.int
hashCode()
boolean
Returns invalidation events disabled status for per entry.void
Reads fields from the input streamprotected void
protected void
protected void
protected void
setAsyncBackupCount
(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 theEvictionConfig
instance 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 theMergePolicyConfig
for this map.void
setMerkleTreeConfig
(MerkleTreeConfig merkleTreeConfig) Sets theMerkleTreeConfig
for thisCacheConfig
Sets 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 forClassLoader
awareness.setWanReplicationRef
(WanReplicationRef wanReplicationRef) toString()
void
Writes object fields to output streamprotected void
protected void
protected void
protected void
Methods 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 theEvictionConfig
instance of the eviction configuration for thisICache
.- Returns:
- the
EvictionConfig
instance of the eviction configuration
-
setEvictionConfig
Sets theEvictionConfig
instance for eviction configuration for thisICache
.- Parameters:
evictionConfig
- theEvictionConfig
instance 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 theMergePolicyConfig
for this map.- Returns:
- the
MergePolicyConfig
for this map
-
setMergePolicyConfig
Sets theMergePolicyConfig
for this map.- Returns:
- the updated map configuration
-
getMerkleTreeConfig
Gets theMerkleTreeConfig
for thisCacheConfig
- Returns:
- merkle tree config
-
setMerkleTreeConfig
Sets theMerkleTreeConfig
for thisCacheConfig
- Parameters:
merkleTreeConfig
- merkle tree config
-
isDisablePerEntryInvalidationEvents
public boolean isDisablePerEntryInvalidationEvents()Returns invalidation events disabled status for per entry.- Returns:
true
if invalidation events are disabled for per entry,false
otherwise
-
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 forClassLoader
awareness during operations related to the structure associated with this configuration.- Specified by:
getUserCodeNamespace
in interfaceUserCodeNamespaceAwareConfig<K>
- Returns:
- Namespace Name for use with the
UserCodeNamespaceService
, ornull
if there is no User Code Namespace to associate with.
-
setUserCodeNamespace
Associates the provided Namespace Name with this structure forClassLoader
awareness.The behaviour of setting this to
null
is outlined in the documentation forUserCodeNamespaceAwareConfig.DEFAULT_NAMESPACE
.- Specified by:
setUserCodeNamespace
in interfaceUserCodeNamespaceAwareConfig<K>
- Parameters:
userCodeNamespace
- The ID of the Namespace to associate with this structure.- Returns:
- the updated
ExecutorConfig
instance - Since:
- 5.4
-
writeData
Description copied from interface:DataSerializable
Writes object fields to output stream- Specified by:
writeData
in interfaceDataSerializable
- Parameters:
out
- output- Throws:
IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the output stream has been closed.
-
getClassId
public int getClassId()Description copied from interface:IdentifiedDataSerializable
Returns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassId
in interfaceIdentifiedDataSerializable
- Returns:
- type ID
-
readData
Description copied from interface:DataSerializable
Reads fields from the input stream- Specified by:
readData
in interfaceDataSerializable
- Parameters:
in
- input- Throws:
IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the input stream has been closed.
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractCacheConfig<K,
V>
-
equals
- Overrides:
equals
in 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 giventarget
object 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 actualkeyType
andvalueType
will be copied. Otherwise, this configuration'skeyClassName
andvalueClassName
will be copied to the target config, to be resolved at a later time.- Returns:
- the target config
-