com.hazelcast.config

## Class NearCacheConfig

- java.lang.Object
- - com.hazelcast.config.NearCacheConfig

- All Implemented Interfaces:
    DataSerializable, IdentifiedDataSerializable, Serializable
  Direct Known Subclasses:
    NearCacheConfigReadOnly

      public class NearCacheConfig
      extends Object
      implements IdentifiedDataSerializable, Serializable

  Contains the configuration for a Near Cache.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `NearCacheConfig.LocalUpdatePolicy` Defines how to reflect local updates to the Near Cache.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DEFAULT_EVICTION_POLICY` Deprecated. since 3.8, please use `EvictionConfig.DEFAULT_EVICTION_POLICY`
    `static boolean` | `DEFAULT_INVALIDATE_ON_CHANGE`
    `static NearCacheConfig.LocalUpdatePolicy` | `DEFAULT_LOCAL_UPDATE_POLICY`
    `static int` | `DEFAULT_MAX_IDLE_SECONDS` Default value of the maximum idle time for eviction in seconds.
    `static int` | `DEFAULT_MAX_SIZE` Deprecated. since 3.8, please use `EvictionConfig.DEFAULT_MAX_ENTRY_COUNT_FOR_ON_HEAP_MAP`
    `static InMemoryFormat` | `DEFAULT_MEMORY_FORMAT` Default value for the in-memory format.
    `static boolean` | `DEFAULT_SERIALIZE_KEYS` Do not serialize by default
    `static int` | `DEFAULT_TTL_SECONDS` Default value of the time to live in seconds.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NearCacheConfig()`
    `NearCacheConfig(int timeToLiveSeconds, int maxIdleSeconds, boolean invalidateOnChange, InMemoryFormat inMemoryFormat)`
    `NearCacheConfig(int timeToLiveSeconds, int maxIdleSeconds, boolean invalidateOnChange, InMemoryFormat inMemoryFormat, EvictionConfig evictionConfig)`
    `NearCacheConfig(int timeToLiveSeconds, int maxSize, String evictionPolicy, int maxIdleSeconds, boolean invalidateOnChange, InMemoryFormat inMemoryFormat)` Deprecated. since 3.8, please use `NearCacheConfig(int, int, boolean, InMemoryFormat)`
    `NearCacheConfig(int timeToLiveSeconds, int maxSize, String evictionPolicy, int maxIdleSeconds, boolean invalidateOnChange, InMemoryFormat inMemoryFormat, EvictionConfig evictionConfig)` Deprecated. since 3.8, please use `NearCacheConfig(int, int, boolean, InMemoryFormat, EvictionConfig)`
    `NearCacheConfig(NearCacheConfig config)`
    `NearCacheConfig(String name)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)`
    `NearCacheConfigReadOnly` | `getAsReadOnly()` Deprecated. this method will be removed in 4.0; it is meant for internal usage only
    `EvictionConfig` | `getEvictionConfig()` Returns the eviction configuration for this Near Cache.
    `String` | `getEvictionPolicy()` Deprecated. since 3.8, please use `getEvictionConfig()` and `EvictionConfig.getEvictionPolicy()`
    `int` | `getFactoryId()` Returns DataSerializableFactory factory ID for this class.
    `int` | `getId()` Returns type identifier for this class.
    `InMemoryFormat` | `getInMemoryFormat()` Returns the data type used to store entries.
    `NearCacheConfig.LocalUpdatePolicy` | `getLocalUpdatePolicy()` Returns the `NearCacheConfig.LocalUpdatePolicy` of this Near Cache.
    `int` | `getMaxIdleSeconds()` Returns the maximum number of seconds each entry can stay in the Near Cache as untouched (not-read).
    `int` | `getMaxSize()` Deprecated. since 3.8, please use `getEvictionConfig()` and `EvictionConfig.getSize()`
    `String` | `getName()` Returns the name of the Near Cache.
    `NearCachePreloaderConfig` | `getPreloaderConfig()` Returns the `NearCachePreloaderConfig` of this Near Cache.
    `int` | `getTimeToLiveSeconds()` Returns the maximum number of seconds for each entry to stay in the Near Cache (time to live).
    `int` | `hashCode()`
    `boolean` | `isCacheLocalEntries()` Checks if local entries are also cached in the Near Cache.
    `boolean` | `isInvalidateOnChange()` Checks if Near Cache entries are invalidated when the entries in the backing data structure are changed (updated or removed).
    `boolean` | `isSerializeKeys()` Checks if the Near Cache key is stored in serialized format or by-reference.
    `void` | `readData(ObjectDataInput in)` Reads fields from the input stream
    `NearCacheConfig` | `setCacheLocalEntries(boolean cacheLocalEntries)` Sets if local entries are also cached in the Near Cache.
    `NearCacheConfig` | `setEvictionConfig(EvictionConfig evictionConfig)` Sets the eviction configuration for this Near Cache.
    `NearCacheConfig` | `setEvictionPolicy(String evictionPolicy)` Deprecated. since 3.8, please use `getEvictionConfig()` and `EvictionConfig.setEvictionPolicy(EvictionPolicy)`
    `NearCacheConfig` | `setInMemoryFormat(InMemoryFormat inMemoryFormat)` Sets the data type used to store entries.
    `NearCacheConfig` | `setInMemoryFormat(String inMemoryFormat)`
    `NearCacheConfig` | `setInvalidateOnChange(boolean invalidateOnChange)` Sets if Near Cache entries are invalidated when the entries in the backing data structure are changed (updated or removed).
    `NearCacheConfig` | `setLocalUpdatePolicy(NearCacheConfig.LocalUpdatePolicy localUpdatePolicy)` Sets the `NearCacheConfig.LocalUpdatePolicy` of this Near Cache.
    `NearCacheConfig` | `setMaxIdleSeconds(int maxIdleSeconds)` Set the maximum number of seconds each entry can stay in the Near Cache as untouched (not-read).
    `NearCacheConfig` | `setMaxSize(int maxSize)` Deprecated. since 3.8, please use `setEvictionConfig(EvictionConfig)` and `EvictionConfig.setSize(int)`
    `NearCacheConfig` | `setName(String name)` Sets the name of the Near Cache.
    `NearCacheConfig` | `setPreloaderConfig(NearCachePreloaderConfig preloaderConfig)` Sets the `NearCachePreloaderConfig` of this Near Cache.
    `NearCacheConfig` | `setSerializeKeys(boolean serializeKeys)` Sets if the Near Cache key is stored in serialized format or by-reference.
    `NearCacheConfig` | `setTimeToLiveSeconds(int timeToLiveSeconds)` Returns the maximum number of seconds for each entry to stay in the Near Cache (time to live).
    `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

    - #### DEFAULT_MEMORY_FORMAT

          public static final InMemoryFormat DEFAULT_MEMORY_FORMAT

      Default value for the in-memory format.

    - #### DEFAULT_SERIALIZE_KEYS

          public static final boolean DEFAULT_SERIALIZE_KEYS

      Do not serialize by default
      See Also:
        Constant Field Values

    - #### DEFAULT_INVALIDATE_ON_CHANGE

          public static final boolean DEFAULT_INVALIDATE_ON_CHANGE

      See Also:
        `NearCacheConfig.LocalUpdatePolicy.INVALIDATE`, Constant Field Values

    - #### DEFAULT_LOCAL_UPDATE_POLICY

          public static final NearCacheConfig.LocalUpdatePolicy DEFAULT_LOCAL_UPDATE_POLICY

      See Also:
        `NearCacheConfig.LocalUpdatePolicy.INVALIDATE`

    - #### DEFAULT_TTL_SECONDS

          public static final int DEFAULT_TTL_SECONDS

      Default value of the time to live in seconds.
      See Also:
        Constant Field Values

    - #### DEFAULT_MAX_IDLE_SECONDS

          public static final int DEFAULT_MAX_IDLE_SECONDS

      Default value of the maximum idle time for eviction in seconds.
      See Also:
        Constant Field Values

    - #### DEFAULT_MAX_SIZE

          @Deprecated
          public static final int DEFAULT_MAX_SIZE

      Deprecated. since 3.8, please use `EvictionConfig.DEFAULT_MAX_ENTRY_COUNT_FOR_ON_HEAP_MAP`
      Default value of the maximum size.
      See Also:
        Constant Field Values

    - #### DEFAULT_EVICTION_POLICY

          @Deprecated
          public static final String DEFAULT_EVICTION_POLICY

      Deprecated. since 3.8, please use `EvictionConfig.DEFAULT_EVICTION_POLICY`
      Default value for the eviction policy.

  - ### Constructor Detail

    - #### NearCacheConfig

          public NearCacheConfig()

    - #### NearCacheConfig

          public NearCacheConfig(String name)

    - #### NearCacheConfig

          public NearCacheConfig(int timeToLiveSeconds,
                                 int maxIdleSeconds,
                                 boolean invalidateOnChange,
                                 InMemoryFormat inMemoryFormat)

    - #### NearCacheConfig

          public NearCacheConfig(int timeToLiveSeconds,
                                 int maxIdleSeconds,
                                 boolean invalidateOnChange,
                                 InMemoryFormat inMemoryFormat,
                                 EvictionConfig evictionConfig)

    - #### NearCacheConfig

          @Deprecated
          public NearCacheConfig(int timeToLiveSeconds,
                                             int maxSize,
                                             String evictionPolicy,
                                             int maxIdleSeconds,
                                             boolean invalidateOnChange,
                                             InMemoryFormat inMemoryFormat)

      Deprecated. since 3.8, please use `NearCacheConfig(int, int, boolean, InMemoryFormat)`

    - #### NearCacheConfig

          @Deprecated
          public NearCacheConfig(int timeToLiveSeconds,
                                             int maxSize,
                                             String evictionPolicy,
                                             int maxIdleSeconds,
                                             boolean invalidateOnChange,
                                             InMemoryFormat inMemoryFormat,
                                             EvictionConfig evictionConfig)

      Deprecated. since 3.8, please use `NearCacheConfig(int, int, boolean, InMemoryFormat, EvictionConfig)`

    - #### NearCacheConfig

          public NearCacheConfig(NearCacheConfig config)

  - ### Method Detail

    - #### getAsReadOnly

          @Deprecated
          public NearCacheConfigReadOnly getAsReadOnly()

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

    - #### getName

          public String getName()

      Returns the name of the Near Cache.
      Returns:
        the name of the Near Cache

    - #### setName

          public NearCacheConfig setName(String name)

      Sets the name of the Near Cache.
      Parameters:
        `name` - the name of the Near Cache
      Returns:
        this Near Cache config instance

    - #### getInMemoryFormat

          public InMemoryFormat getInMemoryFormat()

      Returns the data type used to store entries.

      Possible values:

      - `BINARY`: keys and values are stored as binary data
      - `OBJECT`: values are stored in their object forms
      - `NATIVE`: keys and values are stored in native memory
      The default value is `BINARY`.
      Returns:
        the data type used to store entries

    - #### setInMemoryFormat

          public NearCacheConfig setInMemoryFormat(InMemoryFormat inMemoryFormat)

      Sets the data type used to store entries.

      Possible values:

      - `BINARY`: keys and values are stored as binary data
      - `OBJECT`: values are stored in their object forms
      - `NATIVE`: keys and values are stored in native memory
      The default value is `BINARY`.
      Parameters:
        `inMemoryFormat` - the data type used to store entries
      Returns:
        this Near Cache config instance

    - #### setInMemoryFormat

          public NearCacheConfig setInMemoryFormat(String inMemoryFormat)

    - #### isSerializeKeys

          public boolean isSerializeKeys()

      Checks if the Near Cache key is stored in serialized format or by-reference. NOTE: When the in-memory-format is `NATIVE`, this method will always return `true`.
      Returns:
        `true` if the key is stored in serialized format or in-memory-format is `NATIVE`, `false` if the key is stored by-reference and in-memory-format is `BINARY` or `OBJECT`

    - #### setSerializeKeys

          public NearCacheConfig setSerializeKeys(boolean serializeKeys)

      Sets if the Near Cache key is stored in serialized format or by-reference. NOTE: It's not supported to disable the key serialization when the in-memory-format is `NATIVE`. You can still set this value to `false`, but it will have no effect.
      Parameters:
        `serializeKeys` - `true` if the key is stored in serialized format, `false` if stored by-reference
      Returns:
        this Near Cache config instance

    - #### isInvalidateOnChange

          public boolean isInvalidateOnChange()

      Checks if Near Cache entries are invalidated when the entries in the backing data structure are changed (updated or removed).

      When this setting is enabled, a Hazelcast instance with a Near Cache listens for cluster-wide changes on the entries of the backing data structure and invalidates its corresponding Near Cache entries. Changes done on the local Hazelcast instance always invalidate the Near Cache immediately.

      Returns:
        `true` if Near Cache invalidations are enabled on changes, `false` otherwise

    - #### setInvalidateOnChange

          public NearCacheConfig setInvalidateOnChange(boolean invalidateOnChange)

      Sets if Near Cache entries are invalidated when the entries in the backing data structure are changed (updated or removed).

      When this setting is enabled, a Hazelcast instance with a Near Cache listens for cluster-wide changes on the entries of the backing data structure and invalidates its corresponding Near Cache entries. Changes done on the local Hazelcast instance always invalidate the Near Cache immediately.

      Parameters:
        `invalidateOnChange` - `true` to enable Near Cache invalidations, `false` otherwise
      Returns:
        this Near Cache config instance

    - #### getTimeToLiveSeconds

          public int getTimeToLiveSeconds()

      Returns the maximum number of seconds for each entry to stay in the Near Cache (time to live).

      Entries that are older than `timeToLiveSeconds` will automatically be evicted from the Near Cache.

      Returns:
        the maximum number of seconds for each entry to stay in the Near Cache

    - #### setTimeToLiveSeconds

          public NearCacheConfig setTimeToLiveSeconds(int timeToLiveSeconds)

      Returns the maximum number of seconds for each entry to stay in the Near Cache (time to live).

      Entries that are older than `timeToLiveSeconds` will automatically be evicted from the Near Cache.

      Accepts any integer between `0` and `Integer.MAX_VALUE`. The value `0` means `Integer.MAX_VALUE`. The default is `0`.

      Parameters:
        `timeToLiveSeconds` - the maximum number of seconds for each entry to stay in the Near Cache
      Returns:
        this Near Cache config instance

    - #### getMaxIdleSeconds

          public int getMaxIdleSeconds()

      Returns the maximum number of seconds each entry can stay in the Near Cache as untouched (not-read).

      Entries that are not read (touched) more than `maxIdleSeconds` value will get removed from the Near Cache.

      Returns:
        maximum number of seconds each entry can stay in the Near Cache as untouched (not-read)

    - #### setMaxIdleSeconds

          public NearCacheConfig setMaxIdleSeconds(int maxIdleSeconds)

      Set the maximum number of seconds each entry can stay in the Near Cache as untouched (not-read).

      Entries that are not read (touched) more than `maxIdleSeconds` value will get removed from the Near Cache.

      Accepts any integer between `0` and `Integer.MAX_VALUE`. The value `0` means `Integer.MAX_VALUE`. The default is `0`.

      Parameters:
        `maxIdleSeconds` - maximum number of seconds each entry can stay in the Near Cache as untouched (not-read)
      Returns:
        this Near Cache config instance

    - #### getMaxSize

          @Deprecated
          public int getMaxSize()

      Deprecated. since 3.8, please use `getEvictionConfig()` and `EvictionConfig.getSize()`
      Returns the maximum size of the Near Cache.

      When the maxSize is reached, the Near Cache is evicted based on the policy defined.

      Returns:
        the maximum size of the Near Cache

    - #### setMaxSize

          @Deprecated
          public NearCacheConfig setMaxSize(int maxSize)

      Deprecated. since 3.8, please use `setEvictionConfig(EvictionConfig)` and `EvictionConfig.setSize(int)`
      Sets the maximum size of the Near Cache.

      When the maxSize is reached, the Near Cache is evicted based on the policy defined.

      Accepts any integer between `0` and `Integer.MAX_VALUE`. The value `0` means `Integer.MAX_VALUE`. The default is `0`.

      Parameters:
        `maxSize` - the maximum size of the Near Cache
      Returns:
        this Near Cache config instance

    - #### getEvictionPolicy

          @Deprecated
          public String getEvictionPolicy()

      Deprecated. since 3.8, please use `getEvictionConfig()` and `EvictionConfig.getEvictionPolicy()`
      Returns the eviction policy for the Near Cache.
      Returns:
        the eviction policy for the Near Cache

    - #### setEvictionPolicy

          @Deprecated
          public NearCacheConfig setEvictionPolicy(String evictionPolicy)

      Deprecated. since 3.8, please use `getEvictionConfig()` and `EvictionConfig.setEvictionPolicy(EvictionPolicy)`
      Sets the eviction policy.

      Valid values are:

      - `LRU` (Least Recently Used)
      - `LFU` (Least Frequently Used)
      - `NONE` (no extra eviction, time-to-live-seconds or max-idle-seconds may still apply)
      - `RANDOM` (random entry)

      `LRU` is the default. Regardless of the eviction policy used, time-to-live-seconds and max-idle-seconds will still apply.

      Parameters:
        `evictionPolicy` - the eviction policy for the Near Cache
      Returns:
        this Near Cache config instance

    - #### getEvictionConfig

          public EvictionConfig getEvictionConfig()

      Returns the eviction configuration for this Near Cache.
      Returns:
        the eviction configuration

    - #### setEvictionConfig

          public NearCacheConfig setEvictionConfig(EvictionConfig evictionConfig)

      Sets the eviction configuration for this Near Cache.
      Parameters:
        `evictionConfig` - the eviction configuration
      Returns:
        this Near Cache config instance

    - #### isCacheLocalEntries

          public boolean isCacheLocalEntries()

      Checks if local entries are also cached in the Near Cache.

      This is useful when the in-memory format of the Near Cache is different from the backing data structure. This setting has no meaning on Hazelcast clients, since they have no local entries.

      Returns:
        `true` if local entries are also cached, `false` otherwise

    - #### setCacheLocalEntries

          public NearCacheConfig setCacheLocalEntries(boolean cacheLocalEntries)

      Sets if local entries are also cached in the Near Cache.

      This is useful when the in-memory format of the Near Cache is different from the backing data structure. This setting has no meaning on Hazelcast clients, since they have no local entries.

      Parameters:
        `cacheLocalEntries` - `true` if local entries are also cached, `false` otherwise
      Returns:
        this Near Cache config instance

    - #### getLocalUpdatePolicy

          public NearCacheConfig.LocalUpdatePolicy getLocalUpdatePolicy()

      Returns the `NearCacheConfig.LocalUpdatePolicy` of this Near Cache.
      Returns:
        the `NearCacheConfig.LocalUpdatePolicy` of this Near Cache

    - #### setLocalUpdatePolicy

          public NearCacheConfig setLocalUpdatePolicy(NearCacheConfig.LocalUpdatePolicy localUpdatePolicy)

      Sets the `NearCacheConfig.LocalUpdatePolicy` of this Near Cache.

      This is only implemented for `JCache` data structures.

      Parameters:
        `localUpdatePolicy` - the `NearCacheConfig.LocalUpdatePolicy` of this Near Cache
      Returns:
        this Near Cache config instance

    - #### getPreloaderConfig

          public NearCachePreloaderConfig getPreloaderConfig()

      Returns the `NearCachePreloaderConfig` of this Near Cache.
      Returns:
        the `NearCachePreloaderConfig` of this Near Cache

    - #### setPreloaderConfig

          public NearCacheConfig setPreloaderConfig(NearCachePreloaderConfig preloaderConfig)

      Sets the `NearCachePreloaderConfig` of this Near Cache.
      Parameters:
        `preloaderConfig` - the `NearCachePreloaderConfig` of this Near Cache
      Returns:
        this Near Cache config instance

    - #### getFactoryId

          public int getFactoryId()

      Description copied from interface: `IdentifiedDataSerializable`
      Returns DataSerializableFactory factory ID for this class.
      Specified by:
        `getFactoryId` in interface `IdentifiedDataSerializable`
      Returns:
        factory ID

    - #### getId

          public int getId()

      Description copied from interface: `IdentifiedDataSerializable`
      Returns type identifier for this class. It should be unique per DataSerializableFactory.
      Specified by:
        `getId` in interface `IdentifiedDataSerializable`
      Returns:
        type ID

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

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

Copyright © 2018. All rights reserved.