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 type
    `V` - the value type
  All Implemented Interfaces:
    CacheConfiguration<K,V>, DataSerializable, SplitBrainMergeTypeProvider, Serializable, javax.cache.configuration.CompleteConfiguration<K,V>, javax.cache.configuration.Configuration<K,V>
  Direct Known Subclasses:
    CacheConfigReadOnly

      public class CacheConfig<K,V>
      extends AbstractCacheConfig<K,V>
      implements SplitBrainMergeTypeProvider

  Contains all the configuration for the `ICache`.
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class com.hazelcast.config.AbstractCacheConfig

      `cacheLoaderFactory, cacheWriterFactory, classLoader, expiryPolicyFactory, hotRestartConfig, isManagementEnabled, isReadThrough, isStatisticsEnabled, isStoreByValue, isWriteThrough, listenerConfigurations, serializationService`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CacheConfig()`
    `CacheConfig(CacheSimpleConfig simpleConfig)`
    `CacheConfig(javax.cache.configuration.CompleteConfiguration<K,V> configuration)`
    `CacheConfig(String name)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T extends CacheConfig<K,V>> T` | `copy(T target, boolean resolved)` Copy this CacheConfig to given `target` object whose type extends CacheConfig.
    `boolean` | `equals(Object o)`
    `CacheConfigReadOnly<K,V>` | `getAsReadOnly()` Deprecated. this method will be removed in 4.0; it is meant for internal usage only
    `int` | `getAsyncBackupCount()` Gets the number of asynchronous backups for this `ICache`.
    `int` | `getBackupCount()` Gets the number of synchronous backups for this `ICache`.
    `CacheEvictionConfig` | `getEvictionConfig()` Gets the `EvictionConfig` instance of the eviction configuration for this `ICache`.
    `InMemoryFormat` | `getInMemoryFormat()` Gets the data type that will be used to store records.
    `String` | `getManagerPrefix()` Gets the manager prefix of the `ICache`, such as "hz://".
    `String` | `getMergePolicy()` Gets the class name of `CacheMergePolicy` implementation of this cache config.
    `String` | `getName()` Gets the name of this `ICache`.
    `String` | `getNameWithPrefix()` Gets the full name of the `ICache`, including the manager scope prefix.
    `List<CachePartitionLostListenerConfig>` | `getPartitionLostListenerConfigs()` Gets the partition lost listener references added to cache configuration.
    `Class` | `getProvidedMergeTypes()`
    `String` | `getQuorumName()` Gets the name of the associated quorum if any.
    `int` | `getTotalBackupCount()` Gets the total backup count (`backupCount + asyncBackupCount`) of the cache.
    `String` | `getUriString()` Gets the URI string which is the global identifier for this `ICache`.
    `WanReplicationRef` | `getWanReplicationRef()`
    `int` | `hashCode()`
    `boolean` | `isDisablePerEntryInvalidationEvents()` Returns invalidation events disabled status for per entry.
    `void` | `readData(ObjectDataInput in)` Reads fields from the input stream
    `protected void` | `readFactories(ObjectDataInput in)`
    `protected void` | `readKeyValueTypes(ObjectDataInput in)`
    `protected void` | `readListenerConfigurations(ObjectDataInput in)`
    `protected void` | `readTenant(ObjectDataInput in)`
    `CacheConfig<K,V>` | `setAsyncBackupCount(int asyncBackupCount)` Sets the number of asynchronous backups for this `ICache`.
    `CacheConfig<K,V>` | `setBackupCount(int backupCount)` Sets the number of synchronous backups.
    `void` | `setDisablePerEntryInvalidationEvents(boolean disablePerEntryInvalidationEvents)` Sets invalidation events disabled status for per entry.
    `CacheConfig<K,V>` | `setEvictionConfig(EvictionConfig evictionConfig)` Sets the `EvictionConfig` instance for eviction configuration for this `ICache`.
    `CacheConfig<K,V>` | `setInMemoryFormat(InMemoryFormat inMemoryFormat)` Data type that will be used to store records in this `ICache`.
    `CacheConfig<K,V>` | `setManagerPrefix(String managerPrefix)` Sets the manager prefix of the `ICache`.
    `void` | `setMergePolicy(String mergePolicy)` Sets the class name of `CacheMergePolicy` implementation to this cache config.
    `CacheConfig<K,V>` | `setName(String name)` Sets the name of this `ICache`.
    `CacheConfig<K,V>` | `setPartitionLostListenerConfigs(List<CachePartitionLostListenerConfig> partitionLostListenerConfigs)` Sets the WAN target replication reference.
    `CacheConfig<K,V>` | `setQuorumName(String quorumName)` Associates this cache configuration to a quorum.
    `CacheConfig<K,V>` | `setUriString(String uriString)` Sets the URI string, which is the global identifier of the `ICache`.
    `CacheConfig<K,V>` | `setWanReplicationRef(WanReplicationRef wanReplicationRef)`
    `String` | `toString()`
    `void` | `writeData(ObjectDataOutput out)` Writes object fields to output stream
    `protected void` | `writeFactories(ObjectDataOutput out)`
    `protected void` | `writeKeyValueTypes(ObjectDataOutput out)`
    `protected void` | `writeListenerConfigurations(ObjectDataOutput out)`
    `protected void` | `writeTenant(ObjectDataOutput out)`

    - ### Methods inherited from class com.hazelcast.config.AbstractCacheConfig

      `addCacheEntryListenerConfiguration, createConcurrentSet, getCacheEntryListenerConfigurations, getCacheLoaderFactory, getCacheWriterFactory, getExpiryPolicyFactory, getHotRestartConfig, getKeyClassName, getKeyType, getListenerConfigurations, getValueClassName, getValueType, hasListenerConfiguration, isManagementEnabled, isReadThrough, isStatisticsEnabled, isStoreByValue, isWriteThrough, keyValueTypesEqual, removeCacheEntryListenerConfiguration, setCacheLoaderFactory, setCacheWriterFactory, setClassLoader, setExpiryPolicyFactory, setHotRestartConfig, setKeyClassName, setKeyType, setListenerConfigurations, setListenerConfigurations, setManagementEnabled, setReadThrough, setStatisticsEnabled, setStoreByValue, setTypes, setValueClassName, setValueType, setWriteThrough`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### 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 Detail

    - #### getAsReadOnly

          public CacheConfigReadOnly<K,V> getAsReadOnly()

      Deprecated. this method will be removed in 4.0; it is meant for internal usage only
      Gets immutable version of this configuration.
      Returns:
        immutable version of this configuration

    - #### 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:
        `getAsyncBackupCount()`

    - #### 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:
        `setAsyncBackupCount(int)`

    - #### getAsyncBackupCount

          public int getAsyncBackupCount()

      Gets the number of asynchronous backups for this `ICache`.
      Returns:
        the number of asynchronous backups for this `ICache`
      See Also:
        `setBackupCount(int)`

    - #### 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:
        `setBackupCount(int)`, `getAsyncBackupCount()`

    - #### 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 CacheEvictionConfig 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
      Parameters:
        `inMemoryFormat` - the record type to set
      Returns:
        current cache config instance
      Throws:
        `IllegalArgumentException` - if inMemoryFormat is `null`

    - #### getQuorumName

          public String getQuorumName()

      Gets the name of the associated quorum if any.
      Returns:
        the name of the associated quorum if any

    - #### setQuorumName

          public CacheConfig<K,V> setQuorumName(String quorumName)

      Associates this cache configuration to a quorum.
      Parameters:
        `quorumName` - name of the desired quorum
      Returns:
        the updated CacheConfig

    - #### getMergePolicy

          public String getMergePolicy()

      Gets the class name of `CacheMergePolicy` implementation of this cache config.
      Returns:
        the class name of `CacheMergePolicy` implementation of this cache config

    - #### setMergePolicy

          public void setMergePolicy(String mergePolicy)

      Sets the class name of `CacheMergePolicy` implementation to this cache config.
      Parameters:
        `mergePolicy` - the class name of `CacheMergePolicy` implementation to be set to this cache config

    - #### getProvidedMergeTypes

          public Class getProvidedMergeTypes()

      Specified by:
        `getProvidedMergeTypes` in interface `SplitBrainMergeTypeProvider`

    - #### 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 void 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

    - #### 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.

    - #### 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.
      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

Copyright © 2019. All rights reserved.