public class DefaultNearCache<K,V> extends Object implements NearCache<K,V>
Modifier and Type | Field and Description |
---|---|
protected ClassLoader |
classLoader |
protected ScheduledFuture |
expirationTaskFuture |
protected String |
name |
protected NearCacheConfig |
nearCacheConfig |
protected NearCacheRecordStore<K,V> |
nearCacheRecordStore |
protected TaskScheduler |
scheduler |
protected SerializationService |
serializationService |
CACHED_AS_NULL, DEFAULT_EXPIRATION_TASK_INITIAL_DELAY_SECONDS, DEFAULT_EXPIRATION_TASK_PERIOD_SECONDS, NOT_CACHED, PROP_EXPIRATION_TASK_INITIAL_DELAY_SECONDS, PROP_EXPIRATION_TASK_PERIOD_SECONDS, TASK_INITIAL_DELAY_SECONDS, TASK_PERIOD_SECONDS
Constructor and Description |
---|
DefaultNearCache(String name,
NearCacheConfig nearCacheConfig,
NearCacheRecordStore<K,V> nearCacheRecordStore,
SerializationService serializationService,
TaskScheduler scheduler,
ClassLoader classLoader,
HazelcastProperties properties) |
DefaultNearCache(String name,
NearCacheConfig nearCacheConfig,
SerializationService serializationService,
TaskScheduler scheduler,
ClassLoader classLoader,
HazelcastProperties properties) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all stored values.
|
protected NearCacheRecordStore<K,V> |
createNearCacheRecordStore(String name,
NearCacheConfig nearCacheConfig) |
void |
destroy()
Clears the record store and destroys it.
|
V |
get(K key)
Gets the value associated with the given
key . |
String |
getName()
Gets the name of this
NearCache instance. |
NearCacheRecordStore<K,V> |
getNearCacheRecordStore() |
NearCacheStats |
getNearCacheStats()
Get the
NearCacheStats instance to
monitor this store. |
void |
initialize() |
void |
invalidate(K key)
Removes the value associated with the given
key
and increases the invalidation statistics. |
boolean |
isPreloadDone()
Checks if the pre-loading of the Near Cache is done.
|
boolean |
isSerializeKeys()
Checks if the Near Cache key is stored in serialized format or
by-reference.
|
void |
preload(DataStructureAdapter<Object,?> adapter)
Executes the Near Cache pre-loader on the given
DataStructureAdapter . |
void |
put(K key,
Data keyData,
V value,
Data valueData)
Puts (associates) a value with the given
key . |
int |
size()
Gets the count of stored records.
|
void |
storeKeys()
Stores the keys of the Near Cache.
|
V |
tryPublishReserved(K key,
V value,
long reservationId,
boolean deserialize)
Tries to update reserved key with supplied value.
|
long |
tryReserveForUpdate(K key,
Data keyData)
Tries to reserve supplied key for update.
|
<T> T |
unwrap(Class<T> clazz)
Used to access non-standard methods of an implementation.
|
protected final String name
protected final TaskScheduler scheduler
protected final ClassLoader classLoader
protected final NearCacheConfig nearCacheConfig
protected final SerializationService serializationService
protected ScheduledFuture expirationTaskFuture
protected NearCacheRecordStore<K,V> nearCacheRecordStore
public DefaultNearCache(String name, NearCacheConfig nearCacheConfig, SerializationService serializationService, TaskScheduler scheduler, ClassLoader classLoader, HazelcastProperties properties)
public DefaultNearCache(String name, NearCacheConfig nearCacheConfig, NearCacheRecordStore<K,V> nearCacheRecordStore, SerializationService serializationService, TaskScheduler scheduler, ClassLoader classLoader, HazelcastProperties properties)
public void initialize()
initialize
in interface InitializingObject
protected NearCacheRecordStore<K,V> createNearCacheRecordStore(String name, NearCacheConfig nearCacheConfig)
public String getName()
NearCache
NearCache
instance.public V get(K key)
NearCache
key
.public void put(K key, Data keyData, V value, Data valueData)
NearCache
key
.public void invalidate(K key)
NearCache
key
and increases the invalidation statistics.invalidate
in interface NearCache<K,V>
key
- the key of the value will be invalidatedpublic void clear()
NearCache
public void destroy()
NearCache
public NearCacheStats getNearCacheStats()
NearCache
NearCacheStats
instance to
monitor this store.getNearCacheStats
in interface NearCache<K,V>
NearCacheStats
instance
to monitor this storepublic boolean isSerializeKeys()
NearCache
isSerializeKeys
in interface NearCache<K,V>
true
if the key is stored in serialized format,
false
if stored by-reference.public int size()
NearCache
public void preload(DataStructureAdapter<Object,?> adapter)
NearCache
DataStructureAdapter
.public void storeKeys()
NearCache
public boolean isPreloadDone()
NearCache
isPreloadDone
in interface NearCache<K,V>
true
if the pre-loading is done, false
otherwise.public <T> T unwrap(Class<T> clazz)
NearCache
If this method is called on a wrapper object, result is wrapped object.
public long tryReserveForUpdate(K key, Data keyData)
NearCache
If one thread takes reservation, only that thread can update the key.
tryReserveForUpdate
in interface NearCache<K,V>
key
- key to be reserved for updatekeyData
- key to be reserved for update as Data
NearCacheRecord.NOT_RESERVED
public V tryPublishReserved(K key, V value, long reservationId, boolean deserialize)
NearCache
tryPublishReserved
in interface NearCache<K,V>
key
- reserved key for updatevalue
- value to be associated with reserved keyreservationId
- ID for this reservationdeserialize
- eagerly deserialize
returning valuetrue
and update succeeds, otherwise returns nullpublic NearCacheRecordStore<K,V> getNearCacheRecordStore()
Copyright © 2020 Hazelcast, Inc.. All Rights Reserved.