Class NearCacheConfig

java.lang.Object
com.hazelcast.config.NearCacheConfig
All Implemented Interfaces:
NamedConfig, DataSerializable, IdentifiedDataSerializable, Serializable

public class NearCacheConfig extends Object implements IdentifiedDataSerializable, Serializable, NamedConfig
Contains the configuration for a Near Cache.
See Also:
  • Field Details

  • Constructor Details

    • NearCacheConfig

      public NearCacheConfig()
    • NearCacheConfig

      public NearCacheConfig(String name)
    • NearCacheConfig

      public NearCacheConfig(NearCacheConfig config)
  • Method Details

    • getName

      public String getName()
      Returns the name of the Near Cache.
      Specified by:
      getName in interface NamedConfig
      Returns:
      the name of the Near Cache
    • setName

      public NearCacheConfig setName(String name)
      Sets the name of the Near Cache.
      Specified by:
      setName in interface NamedConfig
      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
    • 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
    • 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
    • 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