Class NearCacheConfig
- All Implemented Interfaces:
NamedConfig,DataSerializable,IdentifiedDataSerializable,Serializable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefines how to reflect local updates to the Near Cache. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanstatic final NearCacheConfig.LocalUpdatePolicystatic final intDefault value of the maximum idle time for eviction in seconds.static final InMemoryFormatDefault value for the in-memory format.static final StringDefault name when it is not set explicitly.static final booleanDo not serialize by defaultstatic final intDefault value of the time to live in seconds. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanintReturns type identifier for this class.Returns the eviction configuration for this Near Cache.intReturns DataSerializableFactory factory ID for this class.Returns the data type used to store entries.Returns theNearCacheConfig.LocalUpdatePolicyof this Near Cache.intReturns the maximum number of seconds each entry can stay in the Near Cache as untouched (not-read).getName()Returns the name of the Near Cache.Returns theNearCachePreloaderConfigof this Near Cache.intReturns the maximum number of seconds for each entry to stay in the Near Cache (time to live).inthashCode()booleanChecks if local entries are also cached in the Near Cache.booleanChecks if Near Cache entries are invalidated when the entries in the backing data structure are changed (updated or removed).booleanChecks if the Near Cache key is stored in serialized format or by-reference.voidReads fields from the input streamsetCacheLocalEntries(boolean cacheLocalEntries) Sets if local entries are also cached in the Near Cache.setEvictionConfig(EvictionConfig evictionConfig) Sets the eviction configuration for this Near Cache.setInMemoryFormat(InMemoryFormat inMemoryFormat) Sets the data type used to store entries.setInMemoryFormat(String inMemoryFormat) setInvalidateOnChange(boolean invalidateOnChange) Sets if Near Cache entries are invalidated when the entries in the backing data structure are changed (updated or removed).setLocalUpdatePolicy(NearCacheConfig.LocalUpdatePolicy localUpdatePolicy) Sets theNearCacheConfig.LocalUpdatePolicyof this Near Cache.setMaxIdleSeconds(int maxIdleSeconds) Set the maximum number of seconds each entry can stay in the Near Cache as untouched (not-read).Sets the name of the Near Cache.setPreloaderConfig(NearCachePreloaderConfig preloaderConfig) Sets theNearCachePreloaderConfigof this Near Cache.setSerializeKeys(boolean serializeKeys) Sets if the Near Cache key is stored in serialized format or by-reference.setTimeToLiveSeconds(int timeToLiveSeconds) Returns the maximum number of seconds for each entry to stay in the Near Cache (time to live).toString()voidWrites object fields to output stream
-
Field Details
-
DEFAULT_MEMORY_FORMAT
Default value for the in-memory format. -
DEFAULT_SERIALIZE_KEYS
public static final boolean DEFAULT_SERIALIZE_KEYSDo not serialize by default- See Also:
-
DEFAULT_INVALIDATE_ON_CHANGE
public static final boolean DEFAULT_INVALIDATE_ON_CHANGE -
DEFAULT_LOCAL_UPDATE_POLICY
-
DEFAULT_TTL_SECONDS
public static final int DEFAULT_TTL_SECONDSDefault value of the time to live in seconds.- See Also:
-
DEFAULT_MAX_IDLE_SECONDS
public static final int DEFAULT_MAX_IDLE_SECONDSDefault value of the maximum idle time for eviction in seconds.- See Also:
-
DEFAULT_NAME
Default name when it is not set explicitly.- See Also:
-
-
Constructor Details
-
NearCacheConfig
public NearCacheConfig() -
NearCacheConfig
-
NearCacheConfig
-
-
Method Details
-
getName
Returns the name of the Near Cache.- Specified by:
getNamein interfaceNamedConfig- Returns:
- the name of the Near Cache
-
setName
Sets the name of the Near Cache.- Specified by:
setNamein interfaceNamedConfig- Parameters:
name- the name of the Near Cache- Returns:
- this Near Cache config instance
-
getInMemoryFormat
Returns the data type used to store entries.Possible values:
BINARY: keys and values are stored as binary dataOBJECT: values are stored in their object formsNATIVE: keys and values are stored in native memory
BINARY.- Returns:
- the data type used to store entries
-
setInMemoryFormat
Sets the data type used to store entries.Possible values:
BINARY: keys and values are stored as binary dataOBJECT: values are stored in their object formsNATIVE: keys and values are stored in native memory
BINARY.- Parameters:
inMemoryFormat- the data type used to store entries- Returns:
- this Near Cache config instance
-
setInMemoryFormat
-
isSerializeKeys
public boolean isSerializeKeys()Checks if the Near Cache key is stored in serialized format or by-reference. NOTE: When the in-memory-format isNATIVE, this method will always returntrue.- Returns:
trueif the key is stored in serialized format or in-memory-format isNATIVE,falseif the key is stored by-reference and in-memory-format isBINARYorOBJECT
-
setSerializeKeys
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 tofalse, but it will have no effect.- Parameters:
serializeKeys-trueif the key is stored in serialized format,falseif 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:
trueif Near Cache invalidations are enabled on changes,falseotherwise
-
setInvalidateOnChange
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-trueto enable Near Cache invalidations,falseotherwise- 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
timeToLiveSecondswill automatically be evicted from the Near Cache.- Returns:
- the maximum number of seconds for each entry to stay in the Near Cache
-
setTimeToLiveSeconds
Returns the maximum number of seconds for each entry to stay in the Near Cache (time to live).Entries that are older than
timeToLiveSecondswill automatically be evicted from the Near Cache.Accepts any integer between
0andInteger.MAX_VALUE. The value0meansInteger.MAX_VALUE. The default is0.- 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
maxIdleSecondsvalue 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
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
maxIdleSecondsvalue will get removed from the Near Cache.Accepts any integer between
0andInteger.MAX_VALUE. The value0meansInteger.MAX_VALUE. The default is0.- 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
Returns the eviction configuration for this Near Cache.- Returns:
- the eviction configuration
-
setEvictionConfig
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:
trueif local entries are also cached,falseotherwise
-
setCacheLocalEntries
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-trueif local entries are also cached,falseotherwise- Returns:
- this Near Cache config instance
-
getLocalUpdatePolicy
Returns theNearCacheConfig.LocalUpdatePolicyof this Near Cache.- Returns:
- the
NearCacheConfig.LocalUpdatePolicyof this Near Cache
-
setLocalUpdatePolicy
Sets theNearCacheConfig.LocalUpdatePolicyof this Near Cache.This is only implemented for
JCachedata structures.- Parameters:
localUpdatePolicy- theNearCacheConfig.LocalUpdatePolicyof this Near Cache- Returns:
- this Near Cache config instance
-
getPreloaderConfig
Returns theNearCachePreloaderConfigof this Near Cache.- Returns:
- the
NearCachePreloaderConfigof this Near Cache
-
setPreloaderConfig
Sets theNearCachePreloaderConfigof this Near Cache.- Parameters:
preloaderConfig- theNearCachePreloaderConfigof this Near Cache- Returns:
- this Near Cache config instance
-
getFactoryId
public int getFactoryId()Description copied from interface:IdentifiedDataSerializableReturns DataSerializableFactory factory ID for this class.- Specified by:
getFactoryIdin interfaceIdentifiedDataSerializable- Returns:
- factory ID
-
getClassId
public int getClassId()Description copied from interface:IdentifiedDataSerializableReturns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassIdin interfaceIdentifiedDataSerializable- Returns:
- type ID
-
writeData
Description copied from interface:DataSerializableWrites object fields to output stream- Specified by:
writeDatain interfaceDataSerializable- Parameters:
out- output- Throws:
IOException- if an I/O error occurs. In particular, anIOExceptionmay be thrown if the output stream has been closed.
-
readData
Description copied from interface:DataSerializableReads fields from the input stream- Specified by:
readDatain interfaceDataSerializable- Parameters:
in- input- Throws:
IOException- if an I/O error occurs. In particular, anIOExceptionmay be thrown if the input stream has been closed.
-
toString
-
equals
-
hashCode
public int hashCode()
-