Class CacheConfig<K,V>

java.lang.Object
com.hazelcast.config.AbstractCacheConfig<K,V>
com.hazelcast.config.CacheConfig<K,V>
Type Parameters:
K - the key type
V - 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:
  • Constructor Details

    • CacheConfig

      public CacheConfig()
    • CacheConfig

      public CacheConfig(String name)
    • CacheConfig

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

      public CacheConfig(CacheSimpleConfig simpleConfig) throws Exception
      Throws:
      Exception
  • Method Details

    • getName

      public String getName()
      Gets the name of this ICache.
      Returns:
      the name of this ICache
    • setName

      public CacheConfig<K,V> setName(String name)
      Sets the name of this ICache.
      Parameters:
      name - the name to set for this ICache
      Returns:
      the current cache config instance
    • getManagerPrefix

      public String getManagerPrefix()
      Gets the manager prefix of the ICache, such as "hz://".
      Returns:
      the manager prefix of this ICache
    • setManagerPrefix

      public CacheConfig<K,V> setManagerPrefix(String managerPrefix)
      Sets the manager prefix of the ICache.
      Parameters:
      managerPrefix - the manager prefix to set for this ICache
      Returns:
      the current cache config instance
    • getUriString

      public String getUriString()
      Gets the URI string which is the global identifier for this ICache.
      Returns:
      the URI string of this ICache
    • setUriString

      public CacheConfig<K,V> setUriString(String uriString)
      Sets the URI string, which is the global identifier of the ICache.
      Parameters:
      uriString - the URI string to set for this ICache
      Returns:
      the current cache config instance
    • getNameWithPrefix

      public String getNameWithPrefix()
      Gets the full name of the ICache, 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 this ICache.
      Returns:
      the number of synchronous backups (backupCount) for this ICache
      See Also:
    • setBackupCount

      public CacheConfig<K,V> setBackupCount(int backupCount)
      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 this ICache
      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 this ICache.
      Returns:
      the number of asynchronous backups for this ICache
      See Also:
    • setAsyncBackupCount

      public CacheConfig<K,V> setAsyncBackupCount(int asyncBackupCount)
      Sets the number of asynchronous backups for this ICache.
      Parameters:
      asyncBackupCount - the number of asynchronous backups to set for this ICache
      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

      public EvictionConfig getEvictionConfig()
      Gets the EvictionConfig instance of the eviction configuration for this ICache.
      Returns:
      the EvictionConfig instance of the eviction configuration
    • setEvictionConfig

      public CacheConfig<K,V> setEvictionConfig(EvictionConfig evictionConfig)
      Sets the EvictionConfig instance for eviction configuration for this ICache.
      Parameters:
      evictionConfig - the EvictionConfig instance to set for the eviction configuration
      Returns:
      the current cache config instance
    • getWanReplicationRef

      public WanReplicationRef getWanReplicationRef()
    • setWanReplicationRef

      public CacheConfig<K,V> setWanReplicationRef(WanReplicationRef wanReplicationRef)
    • getPartitionLostListenerConfigs

      public List<CachePartitionLostListenerConfig> 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

      public InMemoryFormat getInMemoryFormat()
      Gets the data type that will be used to store records.
      Returns:
      the data storage type of the cache config
    • setInMemoryFormat

      public CacheConfig<K,V> setInMemoryFormat(InMemoryFormat inMemoryFormat)
      Data type that will be used to store records in this ICache. 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 is null
    • getSplitBrainProtectionName

      public String getSplitBrainProtectionName()
      Gets the name of the associated split brain protection if any.
      Returns:
      the name of the associated split brain protection if any
    • setSplitBrainProtectionName

      public CacheConfig<K,V> setSplitBrainProtectionName(String splitBrainProtectionName)
      Associates this cache configuration to a split brain protection.
      Parameters:
      splitBrainProtectionName - name of the desired split brain protection
      Returns:
      the updated CacheConfig
    • getMergePolicyConfig

      public MergePolicyConfig getMergePolicyConfig()
      Gets the MergePolicyConfig for this map.
      Returns:
      the MergePolicyConfig for this map
    • setMergePolicyConfig

      public CacheConfig<K,V> setMergePolicyConfig(MergePolicyConfig mergePolicyConfig)
      Sets the MergePolicyConfig for this map.
      Returns:
      the updated map configuration
    • getMerkleTreeConfig

      public MerkleTreeConfig getMerkleTreeConfig()
      Gets the MerkleTreeConfig for this CacheConfig
      Returns:
      merkle tree config
    • setMerkleTreeConfig

      public void setMerkleTreeConfig(MerkleTreeConfig merkleTreeConfig)
      Sets the MerkleTreeConfig for this CacheConfig
      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 is true, otherwise enables it
      Returns:
      this configuration
    • getUserCodeNamespace

      @Nullable public String getUserCodeNamespace()
      Retrieve the User Code Deployment Namespace to be used for ClassLoader awareness during operations related to the structure associated with this configuration.
      Specified by:
      getUserCodeNamespace in interface UserCodeNamespaceAwareConfig<K>
      Returns:
      Namespace Name for use with the UserCodeNamespaceService, or null if there is no User Code Namespace to associate with.
    • setUserCodeNamespace

      public CacheConfig<K,V> setUserCodeNamespace(@Nullable String userCodeNamespace)
      Associates the provided Namespace Name with this structure for ClassLoader awareness.

      The behaviour of setting this to null is outlined in the documentation for UserCodeNamespaceAwareConfig.DEFAULT_NAMESPACE.

      Specified by:
      setUserCodeNamespace in interface UserCodeNamespaceAwareConfig<K>
      Parameters:
      userCodeNamespace - The ID of the Namespace to associate with this structure.
      Returns:
      the updated ExecutorConfig instance
      Since:
      5.4
    • writeData

      public void writeData(ObjectDataOutput out) throws IOException
      Description copied from interface: DataSerializable
      Writes object fields to output stream
      Specified by:
      writeData in interface DataSerializable
      Parameters:
      out - output
      Throws:
      IOException - if an I/O error occurs. In particular, an IOException 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 interface IdentifiedDataSerializable
      Returns:
      type ID
    • readData

      public void readData(ObjectDataInput in) throws IOException
      Description copied from interface: DataSerializable
      Reads fields from the input stream
      Specified by:
      readData in interface DataSerializable
      Parameters:
      in - input
      Throws:
      IOException - if an I/O error occurs. In particular, an IOException may be thrown if the input stream has been closed.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractCacheConfig<K,V>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class AbstractCacheConfig<K,V>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • writeTenant

      protected void writeTenant(ObjectDataOutput out) throws IOException
      Throws:
      IOException
    • readTenant

      protected void readTenant(ObjectDataInput in) throws IOException
      Throws:
      IOException
    • writeKeyValueTypes

      protected void writeKeyValueTypes(ObjectDataOutput out) throws IOException
      Throws:
      IOException
    • readKeyValueTypes

      protected void readKeyValueTypes(ObjectDataInput in) throws IOException
      Throws:
      IOException
    • writeFactories

      protected void writeFactories(ObjectDataOutput out) throws IOException
      Throws:
      IOException
    • readFactories

      protected void readFactories(ObjectDataInput in) throws IOException
      Throws:
      IOException
    • writeListenerConfigurations

      protected void writeListenerConfigurations(ObjectDataOutput out) throws IOException
      Throws:
      IOException
    • readListenerConfigurations

      protected void readListenerConfigurations(ObjectDataInput in) throws IOException
      Throws:
      IOException
    • copy

      public <T extends CacheConfig<K, V>> T copy(T target, boolean resolved)
      Copy this CacheConfig to given target object whose type extends CacheConfig.
      Type Parameters:
      T - the target object type
      Parameters:
      target - the target object to which this configuration will be copied
      resolved - when true, it is assumed that this cacheConfig's key-value types have already been or will be resolved to loaded classes and the actual keyType and valueType will be copied. Otherwise, this configuration's keyClassName and valueClassName will be copied to the target config, to be resolved at a later time.
      Returns:
      the target config