public class NearCacheConfig extends Object implements IdentifiedDataSerializable, Serializable
Modifier and Type | Class and Description |
---|---|
static class |
NearCacheConfig.LocalUpdatePolicy
Defines how to reflect local updates to the Near Cache.
|
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 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) |
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
|
public static final InMemoryFormat DEFAULT_MEMORY_FORMAT
public static final boolean DEFAULT_SERIALIZE_KEYS
public static final boolean DEFAULT_INVALIDATE_ON_CHANGE
public static final NearCacheConfig.LocalUpdatePolicy DEFAULT_LOCAL_UPDATE_POLICY
public static final int DEFAULT_TTL_SECONDS
public static final int DEFAULT_MAX_IDLE_SECONDS
@Deprecated public static final int DEFAULT_MAX_SIZE
EvictionConfig.DEFAULT_MAX_ENTRY_COUNT_FOR_ON_HEAP_MAP
@Deprecated public static final String DEFAULT_EVICTION_POLICY
EvictionConfig.DEFAULT_EVICTION_POLICY
public NearCacheConfig()
public NearCacheConfig(String name)
public NearCacheConfig(int timeToLiveSeconds, int maxIdleSeconds, boolean invalidateOnChange, InMemoryFormat inMemoryFormat)
public NearCacheConfig(int timeToLiveSeconds, int maxIdleSeconds, boolean invalidateOnChange, InMemoryFormat inMemoryFormat, EvictionConfig evictionConfig)
@Deprecated public NearCacheConfig(int timeToLiveSeconds, int maxSize, String evictionPolicy, int maxIdleSeconds, boolean invalidateOnChange, InMemoryFormat inMemoryFormat)
NearCacheConfig(int, int, boolean, InMemoryFormat)
@Deprecated public NearCacheConfig(int timeToLiveSeconds, int maxSize, String evictionPolicy, int maxIdleSeconds, boolean invalidateOnChange, InMemoryFormat inMemoryFormat, EvictionConfig evictionConfig)
NearCacheConfig(int, int, boolean, InMemoryFormat, EvictionConfig)
public NearCacheConfig(NearCacheConfig config)
@Deprecated public NearCacheConfigReadOnly getAsReadOnly()
public String getName()
public NearCacheConfig setName(String name)
name
- the name of the Near Cachepublic InMemoryFormat getInMemoryFormat()
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 memoryBINARY
.public NearCacheConfig setInMemoryFormat(InMemoryFormat inMemoryFormat)
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 memoryBINARY
.inMemoryFormat
- the data type used to store entriespublic NearCacheConfig setInMemoryFormat(String inMemoryFormat)
public boolean isSerializeKeys()
NATIVE
, this method will always return true
.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
public NearCacheConfig setSerializeKeys(boolean serializeKeys)
NATIVE
.
You can still set this value to false
, but it will have no effect.serializeKeys
- true
if the key is stored in serialized format, false
if stored by-referencepublic boolean isInvalidateOnChange()
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.
true
if Near Cache invalidations are enabled on changes, false
otherwisepublic NearCacheConfig setInvalidateOnChange(boolean invalidateOnChange)
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.
invalidateOnChange
- true
to enable Near Cache invalidations, false
otherwisepublic int getTimeToLiveSeconds()
Entries that are older than timeToLiveSeconds
will automatically be evicted from the Near Cache.
public NearCacheConfig setTimeToLiveSeconds(int timeToLiveSeconds)
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
.
timeToLiveSeconds
- the maximum number of seconds for each entry to stay in the Near Cachepublic int getMaxIdleSeconds()
Entries that are not read (touched) more than maxIdleSeconds
value will get removed from the Near Cache.
public NearCacheConfig setMaxIdleSeconds(int maxIdleSeconds)
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
.
maxIdleSeconds
- maximum number of seconds each entry can stay in the Near Cache as untouched (not-read)@Deprecated public int getMaxSize()
getEvictionConfig()
and EvictionConfig.getSize()
When the maxSize is reached, the Near Cache is evicted based on the policy defined.
@Deprecated public NearCacheConfig setMaxSize(int maxSize)
setEvictionConfig(EvictionConfig)
and EvictionConfig.setSize(int)
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
.
maxSize
- the maximum size of the Near Cache@Deprecated public String getEvictionPolicy()
getEvictionConfig()
and EvictionConfig.getEvictionPolicy()
@Deprecated public NearCacheConfig setEvictionPolicy(String evictionPolicy)
getEvictionConfig()
and EvictionConfig.setEvictionPolicy(EvictionPolicy)
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.
evictionPolicy
- the eviction policy for the Near Cachepublic EvictionConfig getEvictionConfig()
public NearCacheConfig setEvictionConfig(EvictionConfig evictionConfig)
evictionConfig
- the eviction configurationpublic boolean isCacheLocalEntries()
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.
true
if local entries are also cached, false
otherwisepublic NearCacheConfig setCacheLocalEntries(boolean cacheLocalEntries)
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.
cacheLocalEntries
- true
if local entries are also cached, false
otherwisepublic NearCacheConfig.LocalUpdatePolicy getLocalUpdatePolicy()
NearCacheConfig.LocalUpdatePolicy
of this Near Cache.NearCacheConfig.LocalUpdatePolicy
of this Near Cachepublic NearCacheConfig setLocalUpdatePolicy(NearCacheConfig.LocalUpdatePolicy localUpdatePolicy)
NearCacheConfig.LocalUpdatePolicy
of this Near Cache.
This is only implemented for JCache
data structures.
localUpdatePolicy
- the NearCacheConfig.LocalUpdatePolicy
of this Near Cachepublic NearCachePreloaderConfig getPreloaderConfig()
NearCachePreloaderConfig
of this Near Cache.NearCachePreloaderConfig
of this Near Cachepublic NearCacheConfig setPreloaderConfig(NearCachePreloaderConfig preloaderConfig)
NearCachePreloaderConfig
of this Near Cache.preloaderConfig
- the NearCachePreloaderConfig
of this Near Cachepublic int getFactoryId()
IdentifiedDataSerializable
getFactoryId
in interface IdentifiedDataSerializable
public int getId()
IdentifiedDataSerializable
getId
in interface IdentifiedDataSerializable
public void writeData(ObjectDataOutput out) throws IOException
DataSerializable
writeData
in interface DataSerializable
out
- outputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.public void readData(ObjectDataInput in) throws IOException
DataSerializable
readData
in interface DataSerializable
in
- inputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
input stream has been closed.Copyright © 2018 Hazelcast, Inc.. All rights reserved.