K - key typeV - value typepublic class ClientCacheProxy<K,V> extends ClientProxy implements EventJournalReader<EventJournalCacheEvent<K,V>>, CacheSyncListenerCompleter
ICache implementation for Hazelcast clients.
This proxy is the implementation of ICache and Cache which is returned by
HazelcastClientCacheManager. Represents a cache on client.
This implementation is a thin proxy implementation using hazelcast client infrastructure.
| Modifier and Type | Field and Description |
|---|---|
protected CacheConfig<K,V> |
cacheConfig |
protected String |
name |
protected String |
nameWithPrefix |
protected int |
partitionCount |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addListenerLocally(UUID regId,
javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration,
CacheEventListenerAdaptor<K,V> adaptor) |
UUID |
addPartitionLostListener(CachePartitionLostListener listener)
Adds a CachePartitionLostListener.
|
void |
clear() |
protected void |
clearInternal() |
void |
close() |
boolean |
containsKey(K key) |
protected boolean |
containsKeyInternal(Object key) |
void |
countDownCompletionLatch(int countDownLatchId) |
void |
deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration) |
protected void |
ensureOpen() |
V |
get(K key) |
V |
get(K key,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Retrieves the mapped value of the given key using a custom
ExpiryPolicy. |
Map<K,V> |
getAll(Set<? extends K> keys) |
Map<K,V> |
getAll(Set<? extends K> keys,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Gets a collection of entries from the cache with custom expiry policy, returning them as
Map of the values associated with the set of keys requested. |
protected void |
getAllInternal(Set<? extends K> keys,
Collection<Data> dataKeys,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
List<Object> resultingKeyValuePairs,
long startNanos) |
V |
getAndPut(K key,
V value) |
V |
getAndPut(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Associates the specified value with the specified key in this cache using a custom
ExpiryPolicy,
returning an existing value if one existed. |
InternalCompletableFuture<V> |
getAndPutAsync(K key,
V value)
Asynchronously associates the specified value with the specified key in this cache,
returning an existing value if one existed.
|
InternalCompletableFuture<V> |
getAndPutAsync(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Asynchronously associates the specified value with the specified key in this cache,
returning an existing value if one existed using a custom
ExpiryPolicy. |
V |
getAndRemove(K key) |
InternalCompletableFuture<V> |
getAndRemoveAsync(K key)
Asynchronously removes the entry for a key and returns the previously assigned value or null
if no value was assigned.
|
protected <T> InternalCompletableFuture<T> |
getAndRemoveAsyncInternal(K key) |
protected <T> ClientDelegatingFuture<T> |
getAndRemoveSyncInternal(K key) |
V |
getAndReplace(K key,
V value) |
V |
getAndReplace(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Atomically replaces the assigned value of the given key by the specified value using a
custom
ExpiryPolicy and returns the previously assigned value. |
InternalCompletableFuture<V> |
getAndReplaceAsync(K key,
V value)
Asynchronously replaces the assigned value of the given key by the specified value and returns
the previously assigned value.
|
InternalCompletableFuture<V> |
getAndReplaceAsync(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Asynchronously replaces the assigned value of the given key by the specified value using a
custom
ExpiryPolicy and returns the previously assigned value. |
InternalCompletableFuture<V> |
getAsync(K key)
Asynchronously retrieves the mapped value of the given key using a custom
ExpiryPolicy. |
InternalCompletableFuture<V> |
getAsync(K key,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Asynchronously gets an entry from cache using a custom
ExpiryPolicy. |
protected InternalCompletableFuture<V> |
getAsyncInternal(Object key,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
BiConsumer<V,Throwable> callback) |
javax.cache.CacheManager |
getCacheManager() |
<C extends javax.cache.configuration.Configuration<K,V>> |
getConfiguration(Class<C> clazz) |
protected String |
getDistributedObjectName() |
protected UUID |
getListenerIdLocal(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration) |
CacheStatistics |
getLocalCacheStatistics()
Directly access local Cache Statistics.
|
protected ILogger |
getLogger() |
String |
getPrefixedName()
Returns the unique prefixed name for this DistributedObject.
|
protected V |
getSyncInternal(Object key,
javax.cache.expiry.ExpiryPolicy expiryPolicy) |
protected void |
injectDependencies(Object obj) |
protected <T> T |
invoke(ClientMessage clientMessage) |
protected ClientInvocationFuture |
invoke(ClientMessage req,
Data keyData,
int completionId) |
protected ClientInvocationFuture |
invoke(ClientMessage req,
int partitionId,
int completionId) |
<T> T |
invoke(K key,
javax.cache.processor.EntryProcessor<K,V,T> entryProcessor,
Object... arguments) |
<T> Map<K,javax.cache.processor.EntryProcessorResult<T>> |
invokeAll(Set<? extends K> keys,
javax.cache.processor.EntryProcessor<K,V,T> entryProcessor,
Object... arguments) |
protected Object |
invokeInternal(Object key,
Data epData,
Object... arguments) |
boolean |
isClosed() |
boolean |
isDestroyed()
Determines whether this Cache instance has been destroyed.
|
Iterator<javax.cache.Cache.Entry<K,V>> |
iterator() |
Iterator<javax.cache.Cache.Entry<K,V>> |
iterator(int fetchSize)
Creates and returns a cluster wide iterator
to iterate on all entries owned by this cache.
|
Iterator<javax.cache.Cache.Entry<K,V>> |
iterator(int fetchSize,
int partitionId,
boolean prefetchValues)
Cluster-wide iterator for
ICache |
void |
loadAll(Set<? extends K> keys,
boolean replaceExistingValues,
javax.cache.integration.CompletionListener completionListener) |
protected void |
loadAllInternal(Set<? extends K> keys,
List<Data> dataKeys,
boolean replaceExistingValues,
javax.cache.integration.CompletionListener completionListener) |
protected BiConsumer<V,Throwable> |
newStatsCallbackOrNull(boolean isGet) |
protected long |
nowInNanosOrDefault() |
protected void |
onDestroy()
Called before proxy is destroyed.
|
protected <T> void |
onGetAndRemoveAsyncInternal(K key,
Data keyData,
ClientDelegatingFuture<T> delegatingFuture,
BiConsumer<T,Throwable> callback) |
protected void |
onInitialize()
Called when proxy is created.
|
protected void |
onLoadAll(List<Data> keys,
Object response,
long startNanos) |
protected void |
onPutIfAbsentAsyncInternal(K key,
V value,
Data keyData,
Data valueData,
ClientDelegatingFuture<Boolean> delegatingFuture,
BiConsumer<Boolean,Throwable> callback) |
protected void |
onPutIfAbsentSyncInternal(K key,
V value,
Data keyData,
Data valueData) |
protected void |
onPutSyncInternal(K key,
V value,
Data keyData,
Data valueData) |
protected void |
onRemoveAsyncInternal(Object key,
Data keyData,
ClientDelegatingFuture future,
BiConsumer<Object,Throwable> callback) |
protected void |
onRemoveSyncInternal(Object key,
Data keyData) |
protected <T> void |
onReplaceAndGetAsync(K key,
V value,
Data keyData,
Data valueData,
ClientDelegatingFuture<T> delegatingFuture,
BiConsumer<T,Throwable> callback) |
protected <T> void |
onReplaceInternalAsync(K key,
V value,
Data keyData,
Data valueData,
ClientDelegatingFuture<T> delegatingFuture,
BiConsumer<T,Throwable> callback) |
void |
open()
Opens cache if available (not destroyed).
|
protected void |
postDestroy()
Called after proxy is destroyed.
|
protected boolean |
preDestroy()
Called before proxy is destroyed and determines whether destroy should be done.
|
void |
put(K key,
V value) |
void |
put(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Associates the specified value with the specified key in the cache using a custom
ExpiryPolicy. |
void |
putAll(Map<? extends K,? extends V> map) |
void |
putAll(Map<? extends K,? extends V> map,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Copies all of the entries from the given map to the cache using a custom
ExpiryPolicy. |
protected void |
putAllInternal(Map<? extends K,? extends V> map,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
Map<Object,Data> keyMap,
List<Map.Entry<Data,Data>>[] entriesPerPartition,
long startNanos) |
InternalCompletableFuture<Void> |
putAsync(K key,
V value)
Asynchronously associates the specified value with the specified key in the cache.
|
InternalCompletableFuture<Void> |
putAsync(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Asynchronously associates the specified value with the specified key in the cache using
a custom
ExpiryPolicy. |
protected ClientDelegatingFuture |
putAsyncInternal(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean isGet,
boolean withCompletionEvent,
BiConsumer<V,Throwable> callback) |
boolean |
putIfAbsent(K key,
V value) |
boolean |
putIfAbsent(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Associates the specified key with the given value if and only if there is not yet
a mapping defined for the specified key.
|
InternalCompletableFuture<Boolean> |
putIfAbsentAsync(K key,
V value)
Asynchronously associates the specified key with the given value if and only if there is not yet
a mapping defined for the specified key.
|
InternalCompletableFuture<Boolean> |
putIfAbsentAsync(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Asynchronously associates the specified key with the given value if and only if there is not yet
a mapping defined for the specified key.
|
protected Object |
putIfAbsentInternal(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean withCompletionEvent,
boolean async) |
protected V |
putSyncInternal(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean isGet) |
<T> InternalCompletableFuture<ReadResultSet<T>> |
readFromEventJournal(long startSequence,
int minSize,
int maxSize,
int partitionId,
Predicate<? super EventJournalCacheEvent<K,V>> predicate,
Function<? super EventJournalCacheEvent<K,V>,? extends T> projection)
Reads from the event journal.
|
void |
registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration) |
void |
registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration,
boolean addToConfig)
Registers the provided listener configuration.
|
boolean |
remove(K key) |
boolean |
remove(K key,
V oldValue) |
void |
removeAll() |
void |
removeAll(Set<? extends K> keys) |
protected void |
removeAllInternal() |
protected void |
removeAllKeysInternal(Set<? extends K> keys,
Collection<Data> dataKeys,
long startNanos) |
InternalCompletableFuture<Boolean> |
removeAsync(K key)
Asynchronously removes the mapping for a key from this cache if it is present.
|
InternalCompletableFuture<Boolean> |
removeAsync(K key,
V oldValue)
Asynchronously removes the mapping for the given key if and only if the
currently mapped value equals to the value of
oldValue. |
protected Object |
removeAsyncInternal(K key,
V oldValue,
boolean hasOldValue,
boolean withCompletionEvent,
boolean async) |
protected void |
removeListenerLocally(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration) |
boolean |
removePartitionLostListener(UUID id)
Removes the specified cache partition lost listener.
|
boolean |
replace(K key,
V value) |
boolean |
replace(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Atomically replaces the assigned value of the given key by the specified value
using a custom
ExpiryPolicy. |
boolean |
replace(K key,
V oldValue,
V newValue) |
boolean |
replace(K key,
V oldValue,
V newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Atomically replaces the currently assigned value for the given key with the specified
newValue if and only if the currently assigned value equals the value of
oldValue using a custom ExpiryPolicy. |
protected <T> InternalCompletableFuture<T> |
replaceAndGetAsyncInternal(K key,
V oldValue,
V newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean hasOldValue,
boolean withCompletionEvent,
boolean async) |
InternalCompletableFuture<Boolean> |
replaceAsync(K key,
V value)
Asynchronously replaces the assigned value of the given key by the specified value.
|
InternalCompletableFuture<Boolean> |
replaceAsync(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Asynchronously replaces the assigned value of the given key by the specified value
using a custom
ExpiryPolicy. |
InternalCompletableFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue)
Asynchronously replaces the currently assigned value for the given key with the specified
newValue if and only if the currently assigned value equals the value of
oldValue. |
InternalCompletableFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Asynchronously replaces the currently assigned value for the given key with the specified
newValue if and only if the currently assigned value equals the value of
oldValue using a custom ExpiryPolicy. |
protected <T> InternalCompletableFuture<T> |
replaceAsyncInternal(K key,
V oldValue,
V newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean hasOldValue,
boolean withCompletionEvent,
boolean async) |
protected boolean |
replaceSyncInternal(K key,
V oldValue,
V newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean hasOldValue) |
void |
resetCacheManager()
Reset cache manager of this cache proxy to
null. |
void |
setCacheManager(HazelcastCacheManager cacheManager)
Sets relevant
HazelcastCacheManager to client/server. |
boolean |
setExpiryPolicy(K key,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Associates the specified key with the given
ExpiryPolicy. |
void |
setExpiryPolicy(Set<? extends K> keys,
javax.cache.expiry.ExpiryPolicy policy)
Associates the specified key with the given
ExpiryPolicy. |
protected boolean |
setExpiryPolicyInternal(K key,
javax.cache.expiry.ExpiryPolicy expiryPolicy) |
protected void |
setExpiryPolicyInternal(Set<? extends K> keys,
javax.cache.expiry.ExpiryPolicy policy) |
protected void |
setExpiryPolicyInternal(Set<? extends K> keys,
javax.cache.expiry.ExpiryPolicy policy,
Set<Data> serializedKeys) |
int |
size()
Total entry count.
|
InternalCompletableFuture<EventJournalInitialSubscriberState> |
subscribeToEventJournal(int partitionId)
Subscribe to the event journal for this reader and a specific partition ID.
|
<T> T |
unwrap(Class<T> clazz) |
protected void |
updateCacheListenerConfigOnOtherNodes(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration,
boolean isRegister) |
protected ClientDelegatingFuture<V> |
wrapPutAsyncFuture(K key,
V value,
Data keyData,
Data valueData,
ClientInvocationFuture invocationFuture,
BiConsumer<V,Throwable> callback) |
deregisterListener, destroy, destroyLocally, destroyRemotely, equals, getClient, getContext, getId, getName, getPartitionKey, getSerializationService, getServiceName, hashCode, invoke, invokeOnAddress, invokeOnPartition, invokeOnPartitionInterruptibly, onShutdown, registerListener, toData, toObjectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitcountDownCompletionLatchforEach, spliteratorgetName, getPartitionKey, getServiceNameprotected final String name
protected final String nameWithPrefix
protected final CacheConfig<K,V> cacheConfig
protected int partitionCount
protected void onInitialize()
ClientProxypublic boolean containsKey(K key)
public void loadAll(Set<? extends K> keys, boolean replaceExistingValues, javax.cache.integration.CompletionListener completionListener)
public <C extends javax.cache.configuration.Configuration<K,V>> C getConfiguration(Class<C> clazz)
public <T> T invoke(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments) throws javax.cache.processor.EntryProcessorException
public <T> Map<K,javax.cache.processor.EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProcessor, Object... arguments)
public void registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
public void registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration, boolean addToConfig)
ICacheInternalregisterCacheEntryListener in interface ICacheInternal<K,V>cacheEntryListenerConfiguration - The cache configuration to be used for registering the entry listeneraddToConfig - If true, the configuration is added to the existing listeners in the cache config.public void deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
public Iterator<javax.cache.Cache.Entry<K,V>> iterator(int fetchSize)
ICacheCreates and returns a cluster wide iterator to iterate on all entries owned by this cache.
The ordering of iteration over entries is undefined.
During iteration, any entries that are:
Iterator.next() may return null if the entry is no
longer present, has expired or has been evicted.public Iterator<javax.cache.Cache.Entry<K,V>> iterator(int fetchSize, int partitionId, boolean prefetchValues)
ICacheInternalICacheiterator in interface ICacheInternal<K,V>fetchSize - batch fetching sizepartitionId - partition ID of the entries to iterate onprefetchValues - prefetch valuespublic UUID addPartitionLostListener(CachePartitionLostListener listener)
ICache
The addPartitionLostListener returns a registration ID. This ID is needed to remove the
CachePartitionLostListener using the
ICache.removePartitionLostListener(UUID) method.
There is no check for duplicate registrations, so if you register the listener twice, it will get events twice. IMPORTANT: Please @see com.hazelcast.partition.PartitionLostListener for weaknesses. IMPORTANT: Listeners registered from HazelcastClient may miss some of the cache partition lost events due to design limitations.
addPartitionLostListener in interface ICache<K,V>listener - the added CachePartitionLostListener.ICache.removePartitionLostListener(UUID)public boolean removePartitionLostListener(UUID id)
ICacheremovePartitionLostListener in interface ICache<K,V>id - ID of registered listener.public InternalCompletableFuture<EventJournalInitialSubscriberState> subscribeToEventJournal(int partitionId)
EventJournalReadersubscribeToEventJournal in interface EventJournalReader<EventJournalCacheEvent<K,V>>partitionId - the partition ID of the entries to which we are subscribingCompletionStage with the initial subscriber state containing the newest and oldest event journal sequencepublic <T> InternalCompletableFuture<ReadResultSet<T>> readFromEventJournal(long startSequence, int minSize, int maxSize, int partitionId, Predicate<? super EventJournalCacheEvent<K,V>> predicate, Function<? super EventJournalCacheEvent<K,V>,? extends T> projection)
EventJournalReaderUnsupportedOperationException
if the cluster version is lower than 3.9 or there is no event journal configured for this data structure.
NOTE:
Configuring evictions may cause unexpected results when reading from the event journal and
there are cluster changes (a backup replica is promoted into a partition owner). See
MapEventJournal or
CacheEventJournal for more details.
readFromEventJournal in interface EventJournalReader<EventJournalCacheEvent<K,V>>T - the return type of the projection. It is equal to the journal event type
if the projection is null or it is the identity projectionstartSequence - the sequence of the first item to readmaxSize - the maximum number of items to readpartitionId - the partition ID of the entries in the journalpredicate - the predicate which the events must pass to be included in the response.
May be null in which case all events pass the predicateprojection - the projection which is applied to the events before returning.
May be null in which case the event is returned without being projectedCompletionStage with the filtered and projected journal itemspublic InternalCompletableFuture<V> getAsync(K key)
ICacheExpiryPolicy. If no mapping exists null is returned.
If the cache is configured for read-through operation mode, the underlying
configured CacheLoader might be called to retrieve
the value of the key from any kind of external resource.
The resulting CompletionStage instance may throw a
ClassCastException as the operations result if the Cache
is configured to perform runtime-type-checking, and the key or value types are incompatible
with those that have been configured for the Cache.
public InternalCompletableFuture<V> getAsync(K key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy.
If the cache is configured for read-through operation mode, the underlying
configured CacheLoader might be called to retrieve
the value of the key from any kind of external resource.
The resulting CompletionStage instance may throw a
ClassCastException as the operations result if the Cache
is configured to perform runtime-type-checking, and the key or value types are incompatible
with those that have been configured for the Cache.
getAsync in interface ICache<K,V>key - The key whose associated value is to be returned.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to ICache.getAsync(Object).Cache.get(Object)public InternalCompletableFuture<Void> putAsync(K key, V value)
ICacheIn case a previous assignment already exists, the previous value is overridden by the new given value.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
public InternalCompletableFuture<Void> putAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy.
In case a previous assignment already exists, the previous value is overridden by the new given value.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
putAsync in interface ICache<K,V>key - The key whose associated value is to be returned.value - The value to be associated with the specified key.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to ICache.putAsync(Object, Object).Cache.put(Object, Object)public InternalCompletableFuture<Boolean> putIfAbsentAsync(K key, V value)
ICacheThis is equivalent to:
if (!cache.containsKey(key)) {}
cache.put(key, value);
return true;
} else {
return false;
}
except that the action is performed atomically.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
putIfAbsentAsync in interface ICache<K,V>key - The key that is associated with the specified value.value - The value to which the specified key is associated.Cache.putIfAbsent(Object, Object)public InternalCompletableFuture<Boolean> putIfAbsentAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy.
This is equivalent to:
if (!cache.containsKey(key)) {}
cache.put(key, value);
return true;
} else {
return false;
}
except that the action is performed atomically.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
putIfAbsentAsync in interface ICache<K,V>key - The key that is associated with the specified value.value - The value to which the specified key is associated.expiryPolicy - custom expiry policy for this operation,
a null value is equivalent to
ICache.putIfAbsentAsync(Object, Object)Cache.putIfAbsent(Object, Object)public InternalCompletableFuture<V> getAndPutAsync(K key, V value)
ICache
In case a previous assignment already exists, the previous value is overridden by
the new given value and the previous value is returned to the caller. This is
equivalent to the Map.put(Object, Object) operation.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
getAndPutAsync in interface ICache<K,V>key - The key whose associated value is to be returned.value - The value that is associated with the specified key.Cache.getAndPut(Object, Object)public InternalCompletableFuture<V> getAndPutAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy.
In case a previous assignment already exists, the previous value is overridden by
the new given value and the previous value is returned to the caller. This is
equivalent to the Map.put(Object, Object) operation.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
getAndPutAsync in interface ICache<K,V>key - The key whose associated value is to be returned.value - The value to associate with the specified key.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to ICache.getAndPutAsync(Object, Object).Cache.getAndPut(Object, Object)public InternalCompletableFuture<Boolean> removeAsync(K key)
ICache
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
The resulting CompletionStage instance may throw a
ClassCastException as the operations result if the Cache
is configured to perform runtime-type-checking, and the key or value types are incompatible
with those that have been configured for the Cache.
removeAsync in interface ICache<K,V>key - The key whose mapping is to be removed.Cache.remove(Object)public InternalCompletableFuture<Boolean> removeAsync(K key, V oldValue)
ICacheoldValue.
This is equivalent to:
if (cache.containsKey(key) && equals(cache.get(key), oldValue) {
cache.remove(key);
return true;
} else {
return false;
}
except that the action is performed atomically.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
The resulting CompletionStage instance may throw a
ClassCastException as the operations result if the Cache
is configured to perform runtime-type-checking, and the key or value types are incompatible
with those that have been configured for the Cache.
removeAsync in interface ICache<K,V>key - The key whose mapping is to be removed if the mapped value is oldValue.oldValue - The value expected to be associated with the specified key.Cache.remove(Object, Object)public InternalCompletableFuture<V> getAndRemoveAsync(K key)
ICache
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
The resulting CompletionStage instance may throw a
ClassCastException as the operations result if the Cache
is configured to perform runtime-type-checking, and the key or value types are incompatible
with those that have been configured for the Cache.
getAndRemoveAsync in interface ICache<K,V>key - The key to be removed and whose associated value is to be returned.Cache.getAndRemove(Object)public InternalCompletableFuture<Boolean> replaceAsync(K key, V value)
ICache
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
replaceAsync in interface ICache<K,V>key - The key whose associated value is to be replaced.value - The new value to be associated with the specified key.Cache.replace(Object, Object)public InternalCompletableFuture<Boolean> replaceAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
replaceAsync in interface ICache<K,V>key - The key whose assigned value is replaced by the specified value.value - The specified value to be associated with the given key.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to ICache.replaceAsync(Object, Object)Cache.replace(Object, Object)public InternalCompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
ICachenewValue if and only if the currently assigned value equals the value of
oldValue.
This is equivalent to:
if (cache.containsKey(key) && equals(cache.get(key), oldValue) {
cache.put(key, newValue);
return true;
} else {
return false;
}
except that the action is performed atomically.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
The resulting CompletionStage instance may throw a
ClassCastException as the operations result if the Cache
is configured to perform runtime-type-checking, and the key or value types are incompatible
with those that have been configured for the Cache.
replaceAsync in interface ICache<K,V>key - The key that will have its assigned value replaced.oldValue - The old value expected to be associated with the specified key.newValue - The new value to be associated with the specified key.Cache.replace(Object, Object, Object)public InternalCompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICachenewValue if and only if the currently assigned value equals the value of
oldValue using a custom ExpiryPolicy.
This is equivalent to:
if (cache.containsKey(key) && equals(cache.get(key), oldValue) {
cache.put(key, newValue);
return true;
} else {
return false;
}
except that the action is performed atomically.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
The resulting CompletionStage instance may throw a
ClassCastException as the operations result if the Cache
is configured to perform runtime-type-checking, and the key or value types are incompatible
with those that have been configured for the Cache.
replaceAsync in interface ICache<K,V>key - The key that will have its assigned value replaced.oldValue - The old value expected to be associated with the specified key.newValue - The new value to be associated with the specified key.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to ICache.replaceAsync(Object, Object, Object).Cache.replace(Object, Object, Object)public InternalCompletableFuture<V> getAndReplaceAsync(K key, V value)
ICache
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
getAndReplaceAsync in interface ICache<K,V>key - The key whose value is replaced.value - The new value to be associated with the specified key.Cache.getAndReplace(Object, Object)public InternalCompletableFuture<V> getAndReplaceAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy and returns the previously assigned value.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
getAndReplaceAsync in interface ICache<K,V>key - The key whose value is replaced.value - The new value to be associated with the specified key.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to Cache.getAndReplace(Object, Object)Cache.getAndReplace(Object, Object)public V get(K key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy.
If no mapping exists null is returned.
If the cache is configured for read-through operation mode, the underlying
configured CacheLoader might be called to retrieve
the value of the key from any kind of external resource.
get in interface ICache<K,V>key - The key whose mapped value is to be returned.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to Cache.get(Object).Cache.get(Object)public Map<K,V> getAll(Set<? extends K> keys, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheMap of the values associated with the set of keys requested.
If the cache is configured for read-through operation mode, the underlying
configured CacheLoader might be called to retrieve
the values of the keys from any kind of external resource.
getAll in interface ICache<K,V>keys - The keys whose associated values are to be returned.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to Cache.getAll(java.util.Set).Cache.getAll(java.util.Set)public void put(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy.put in interface ICache<K,V>key - The key that has the specified value associated with it.value - The value to be associated with the key.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to Cache.put(Object, Object).Cache.put(Object, Object)public V getAndPut(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy,
returning an existing value if one existed.getAndPut in interface ICache<K,V>key - The key that has the specified value associated with it.value - The value to be associated with the key.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to Cache.getAndPut(Object, Object).Cache.getAndPut(Object, Object)public void putAll(Map<? extends K,? extends V> map, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy.
Puts of single entries happen atomically but there is no transactional guarantee over
the complete putAll operation. If other concurrent operations modify or remove
all or single values of the provided map, the result is undefined.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the values of the keys to any kind of external resource.
public void setExpiryPolicy(Set<? extends K> keys, javax.cache.expiry.ExpiryPolicy policy)
ICacheExpiryPolicy.
expiryPolicy takes precedence for these particular keys against any cache wide expiry policy.
If some keys in keys do not exist or are already expired, this call has no effect for those.
Note: New time-to-live duration is calculated using newly added entry policy's getExpiryForUpdate method
immediately after this operation succeeds.setExpiryPolicy in interface ICache<K,V>keys - The keys that are associated with the specified expiry policy.policy - custom expiry policy for this operationpublic boolean setExpiryPolicy(K key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy.
expiryPolicy takes precedence for this particular key against any cache wide expiry policy.
If key does not exist or is already expired, this call makes no changes to entries stored in this cache.
Note: New time-to-live duration is calculated using newly added entry policy's getExpiryForUpdate method
immediately after this operation succeeds.setExpiryPolicy in interface ICache<K,V>key - The key that is associated with the specified expiry policy.expiryPolicy - custom expiry policy for this operationtrue if the entry exists and its expiry policy is changed, false otherwisepublic boolean putIfAbsent(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheThis is equivalent to:
if (!cache.containsKey(key)) {}
cache.put(key, value);
return true;
} else {
return false;
}
except that the action is performed atomically.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
putIfAbsent in interface ICache<K,V>key - The key that is associated with the specified value.value - The value that has the specified key associated with it.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to Cache.putIfAbsent(Object, Object).Cache.putIfAbsent(Object, Object)public boolean replace(K key, V oldValue, V newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICachenewValue if and only if the currently assigned value equals the value of
oldValue using a custom ExpiryPolicy.
This is equivalent to:
if (cache.containsKey(key) && equals(cache.get(key), oldValue) {
cache.put(key, newValue);
return true;
} else {
return false;
}
except that the action is performed atomically.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
replace in interface ICache<K,V>key - The key with the value to be replaced.oldValue - The old value expected to be associated with the specified key.newValue - The new value to be associated with the specified key.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to Cache.replace(Object, Object, Object).Cache.replace(Object, Object, Object)public boolean replace(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
replace in interface ICache<K,V>key - The key whose value is replaced.value - The new value to be associated with the specified key.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to Cache.replace(Object, Object)Cache.replace(Object, Object)public V getAndReplace(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy and returns the previously assigned value.
If the cache is configured for write-through operation mode, the underlying
configured CacheWriter might be called to store
the value of the key to any kind of external resource.
getAndReplace in interface ICache<K,V>key - The key whose value is replaced.value - The new value to be associated with the specified key.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to Cache.getAndReplace(Object, Object).Cache.getAndReplace(Object, Object)public int size()
ICachepublic CacheStatistics getLocalCacheStatistics()
ICachegetLocalCacheStatistics in interface ICache<K,V>protected String getDistributedObjectName()
getDistributedObjectName in class ClientProxypublic void close()
close in interface Closeableclose in interface AutoCloseableclose in interface javax.cache.Cache<K,V>protected boolean preDestroy()
ClientProxypreDestroy in class ClientProxytrue if destroy should be done, otherwise falsepublic boolean isClosed()
isClosed in interface javax.cache.Cache<K,V>public boolean isDestroyed()
ICacheisDestroyed in interface ICache<K,V>true if this Cache instance is destroyed; false if it is still open.public void open()
ICacheInternalopen in interface ICacheInternal<K,V>public String getPrefixedName()
PrefixedDistributedObjectgetPrefixedName in interface PrefixedDistributedObjectprotected <T> T invoke(ClientMessage clientMessage)
invoke in class ClientProxypublic void countDownCompletionLatch(int countDownLatchId)
countDownCompletionLatch in interface CacheSyncListenerCompleterpublic javax.cache.CacheManager getCacheManager()
getCacheManager in interface javax.cache.Cache<K,V>public void setCacheManager(HazelcastCacheManager cacheManager)
ICacheInternalHazelcastCacheManager to client/server.setCacheManager in interface ICacheInternal<K,V>cacheManager - client or server HazelcastCacheManagerpublic void resetCacheManager()
ICacheInternalnull. Whenever a Cache is not managed any more
(for example after Cache.close() has been called), its CacheManager should be reset.resetCacheManager in interface ICacheInternal<K,V>protected void postDestroy()
ClientProxypostDestroy in class ClientProxyprotected void onDestroy()
ClientProxyonDestroy in class ClientProxyprotected void ensureOpen()
protected void injectDependencies(Object obj)
protected long nowInNanosOrDefault()
protected ClientInvocationFuture invoke(ClientMessage req, int partitionId, int completionId)
protected ClientInvocationFuture invoke(ClientMessage req, Data keyData, int completionId)
protected <T> InternalCompletableFuture<T> getAndRemoveAsyncInternal(K key)
protected <T> ClientDelegatingFuture<T> getAndRemoveSyncInternal(K key)
protected <T> void onGetAndRemoveAsyncInternal(K key,
Data keyData,
ClientDelegatingFuture<T> delegatingFuture,
BiConsumer<T,Throwable> callback)
protected Object removeAsyncInternal(K key, V oldValue, boolean hasOldValue, boolean withCompletionEvent, boolean async)
protected void onRemoveAsyncInternal(Object key, Data keyData, ClientDelegatingFuture future, BiConsumer<Object,Throwable> callback)
protected boolean replaceSyncInternal(K key,
V oldValue,
V newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean hasOldValue)
protected <T> InternalCompletableFuture<T> replaceAsyncInternal(K key, V oldValue, V newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy, boolean hasOldValue, boolean withCompletionEvent, boolean async)
protected <T> void onReplaceInternalAsync(K key,
V value,
Data keyData,
Data valueData,
ClientDelegatingFuture<T> delegatingFuture,
BiConsumer<T,Throwable> callback)
protected <T> InternalCompletableFuture<T> replaceAndGetAsyncInternal(K key, V oldValue, V newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy, boolean hasOldValue, boolean withCompletionEvent, boolean async)
protected <T> void onReplaceAndGetAsync(K key,
V value,
Data keyData,
Data valueData,
ClientDelegatingFuture<T> delegatingFuture,
BiConsumer<T,Throwable> callback)
protected V putSyncInternal(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean isGet)
protected ClientDelegatingFuture putAsyncInternal(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy, boolean isGet, boolean withCompletionEvent, BiConsumer<V,Throwable> callback)
protected ClientDelegatingFuture<V> wrapPutAsyncFuture(K key, V value, Data keyData, Data valueData, ClientInvocationFuture invocationFuture, BiConsumer<V,Throwable> callback)
protected BiConsumer<V,Throwable> newStatsCallbackOrNull(boolean isGet)
protected boolean setExpiryPolicyInternal(K key,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
protected Object putIfAbsentInternal(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy, boolean withCompletionEvent, boolean async)
protected void onPutIfAbsentAsyncInternal(K key,
V value,
Data keyData,
Data valueData,
ClientDelegatingFuture<Boolean> delegatingFuture,
BiConsumer<Boolean,Throwable> callback)
protected void onPutIfAbsentSyncInternal(K key,
V value,
Data keyData,
Data valueData)
protected void removeAllKeysInternal(Set<? extends K> keys, Collection<Data> dataKeys, long startNanos)
protected void removeAllInternal()
protected void clearInternal()
protected void addListenerLocally(UUID regId, javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration, CacheEventListenerAdaptor<K,V> adaptor)
protected void removeListenerLocally(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
protected UUID getListenerIdLocal(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
protected V getSyncInternal(Object key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
protected InternalCompletableFuture<V> getAsyncInternal(Object key, javax.cache.expiry.ExpiryPolicy expiryPolicy, BiConsumer<V,Throwable> callback)
protected void getAllInternal(Set<? extends K> keys, Collection<Data> dataKeys, javax.cache.expiry.ExpiryPolicy expiryPolicy, List<Object> resultingKeyValuePairs, long startNanos)
protected void setExpiryPolicyInternal(Set<? extends K> keys, javax.cache.expiry.ExpiryPolicy policy)
protected void setExpiryPolicyInternal(Set<? extends K> keys, javax.cache.expiry.ExpiryPolicy policy, Set<Data> serializedKeys)
protected void putAllInternal(Map<? extends K,? extends V> map, javax.cache.expiry.ExpiryPolicy expiryPolicy, Map<Object,Data> keyMap, List<Map.Entry<Data,Data>>[] entriesPerPartition, long startNanos)
protected boolean containsKeyInternal(Object key)
protected void loadAllInternal(Set<? extends K> keys, List<Data> dataKeys, boolean replaceExistingValues, javax.cache.integration.CompletionListener completionListener)
protected void updateCacheListenerConfigOnOtherNodes(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration,
boolean isRegister)
protected ILogger getLogger()
Copyright © 2019 Hazelcast, Inc.. All rights reserved.