K - the type of key.V - the type of value.public class NearCachedClientCacheProxy<K,V> extends ClientCacheProxy<K,V>
ICacheInternal implementation which handles Near Cache specific behaviour of methods.| Modifier and Type | Field and Description |
|---|---|
protected CacheConfig<K,V> |
cacheConfig |
protected AtomicReference<HazelcastClientCacheManager> |
cacheManagerRef |
protected ILogger |
logger |
protected String |
name |
protected String |
nameWithPrefix |
protected int |
partitionCount |
| Modifier and Type | Method and Description |
|---|---|
protected static <T> void |
addCallback(ClientDelegatingFuture<T> delegatingFuture,
ExecutionCallback<T> callback) |
protected void |
addListenerLocally(String regId,
javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration,
CacheEventListenerAdaptor<K,V> adaptor) |
String |
addNearCacheInvalidationListener(EventHandler eventHandler) |
void |
clear() |
protected void |
clearInternal() |
void |
close() |
protected void |
closeListeners() |
protected boolean |
containsKeyInternal(Object key) |
void |
countDownCompletionLatch(int countDownLatchId) |
protected EventHandler |
createHandler(CacheEventListenerAdaptor<K,V> adaptor) |
protected void |
deregisterCompletionLatch(Integer countDownLatchId) |
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,
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,
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. |
ICompletableFuture<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.
|
ICompletableFuture<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. |
ICompletableFuture<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> ICompletableFuture<T> |
getAndRemoveAsyncInternal(K key) |
protected <T> ClientDelegatingFuture<T> |
getAndRemoveSyncInternal(K key) |
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. |
ICompletableFuture<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.
|
ICompletableFuture<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. |
ICompletableFuture<V> |
getAsync(K key)
Asynchronously retrieves the mapped value of the given key using a custom
ExpiryPolicy. |
ICompletableFuture<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,
ExecutionCallback<V> callback) |
protected String |
getDistributedObjectName() |
protected String |
getListenerIdLocal(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration) |
CacheStatistics |
getLocalCacheStatistics()
Directly access local Cache Statistics.
|
String |
getNameWithPrefix()
Deprecated.
use #getPrefixedName instead
|
NearCache |
getNearCache() |
String |
getPrefixedName()
Returns the unique prefixed name for this DistributedObject.
|
protected <T> T |
getSafely(Future<T> future) |
protected V |
getSyncInternal(Object key,
javax.cache.expiry.ExpiryPolicy expiryPolicy) |
protected void |
injectDependencies(Object obj) |
protected <T> T |
invoke(ClientMessage clientMessage) |
protected ClientMessage |
invoke(ClientMessage clientMessage,
Data keyData) |
protected ClientInvocationFuture |
invoke(ClientMessage req,
Data keyData,
int completionId) |
protected ClientInvocationFuture |
invoke(ClientMessage req,
int partitionId,
int completionId) |
protected Object |
invokeInternal(Object key,
Data epData,
Object[] arguments) |
boolean |
isClosed() |
boolean |
isDestroyed()
Determines whether this Cache instance has been destroyed.
|
protected void |
loadAllInternal(Set<? extends K> keys,
List<Data> dataKeys,
boolean replaceExistingValues,
javax.cache.integration.CompletionListener completionListener) |
protected <T> ClientDelegatingFuture<T> |
newDelegatingFuture(ClientInvocationFuture future,
ClientMessageDecoder decoder) |
protected <T> ClientDelegatingFuture<T> |
newDelegatingFuture(ClientInvocationFuture future,
ClientMessageDecoder decoder,
boolean deserializeResponse) |
protected com.hazelcast.client.cache.impl.OneShotExecutionCallback<V> |
newStatsCallbackOrNull(boolean isGet) |
protected int |
nextCompletionId() |
protected void |
onDestroy()
Called before proxy is destroyed.
|
protected <T> void |
onGetAndRemoveAsyncInternal(K key,
Data keyData,
ClientDelegatingFuture<T> delegatingFuture,
ExecutionCallback<T> callback) |
protected void |
onInitialize()
Called when proxy is created.
|
protected void |
onPutIfAbsentAsyncInternal(K key,
V value,
Data keyData,
Data valueData,
ClientDelegatingFuture<Boolean> delegatingFuture,
ExecutionCallback<Boolean> 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,
ExecutionCallback callback) |
void |
onRemoveSyncInternal(Object key,
Data keyData) |
protected <T> void |
onReplaceAndGetAsync(K key,
V value,
Data keyData,
Data valueData,
ClientDelegatingFuture<T> delegatingFuture,
ExecutionCallback<T> callback) |
protected <T> void |
onReplaceInternalAsync(K key,
V value,
Data keyData,
Data valueData,
ClientDelegatingFuture<T> delegatingFuture,
ExecutionCallback<T> 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,
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,
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) |
ICompletableFuture<Void> |
putAsync(K key,
V value)
Asynchronously associates the specified value with the specified key in the cache.
|
ICompletableFuture<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,
com.hazelcast.client.cache.impl.OneShotExecutionCallback<V> callback) |
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.
|
ICompletableFuture<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.
|
ICompletableFuture<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) |
protected Integer |
registerCompletionLatch(Integer countDownLatchId,
int count) |
void |
removeAll() |
protected void |
removeAllInternal() |
protected void |
removeAllKeysInternal(Set<? extends K> keys,
Collection<Data> dataKeys,
long startNanos) |
ICompletableFuture<Boolean> |
removeAsync(K key)
Asynchronously removes the mapping for a key from this cache if it is present.
|
ICompletableFuture<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 String |
removeListenerLocally(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration) |
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,
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> ICompletableFuture<T> |
replaceAndGetAsyncInternal(K key,
V oldValue,
V newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean hasOldValue,
boolean withCompletionEvent,
boolean async) |
ICompletableFuture<Boolean> |
replaceAsync(K key,
V value)
Asynchronously replaces the assigned value of the given key by the specified value.
|
ICompletableFuture<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. |
ICompletableFuture<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.
|
ICompletableFuture<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> ICompletableFuture<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) |
void |
setExpiryPolicyInternal(Set<? extends K> keys,
javax.cache.expiry.ExpiryPolicy expiryPolicy) |
protected void |
setExpiryPolicyInternal(Set<? extends K> keys,
javax.cache.expiry.ExpiryPolicy policy,
Set<Data> serializedKeys) |
int |
size()
Total entry count.
|
protected void |
submitLoadAllTask(ClientMessage request,
javax.cache.integration.CompletionListener completionListener,
List<Data> binaryKeys) |
protected void |
waitCompletionLatch(Integer countDownLatchId,
ICompletableFuture future) |
protected ClientDelegatingFuture<V> |
wrapPutAsyncFuture(K key,
V value,
Data keyData,
Data valueData,
ClientInvocationFuture invocationFuture,
com.hazelcast.client.cache.impl.OneShotExecutionCallback<V> callback) |
addPartitionLostListener, containsKey, deregisterCacheEntryListener, get, getAll, getAndPut, getAndRemove, getAndReplace, getCacheManager, getConfiguration, invoke, invokeAll, iterator, iterator, iterator, loadAll, onLoadAll, put, putAll, putIfAbsent, readFromEventJournal, registerCacheEntryListener, registerCacheEntryListener, remove, remove, removeAll, removePartitionLostListener, replace, replace, subscribeToEventJournal, unwrap, updateCacheListenerConfigOnOtherNodesderegisterListener, destroy, destroyLocally, destroyRemotely, equals, getClient, getConnectedServerVersion, getContext, getId, getName, getPartitionKey, getSerializationService, getServiceName, hashCode, invoke, invokeOnAddress, invokeOnPartition, invokeOnPartitionInterruptibly, onShutdown, registerListener, setContext, toData, toObjectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorgetName, getPartitionKey, getServiceNameprotected final AtomicReference<HazelcastClientCacheManager> cacheManagerRef
protected int partitionCount
protected final String name
protected final String nameWithPrefix
protected final CacheConfig<K,V> cacheConfig
protected ILogger logger
public NearCache getNearCache()
protected void onInitialize()
ClientProxyonInitialize in class ClientCacheProxy<K,V>protected V getSyncInternal(Object key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
protected InternalCompletableFuture<V> getAsyncInternal(Object key, javax.cache.expiry.ExpiryPolicy expiryPolicy, ExecutionCallback<V> callback)
protected void onPutIfAbsentSyncInternal(K key, V value, Data keyData, Data valueData)
protected void onPutIfAbsentAsyncInternal(K key, V value, Data keyData, Data valueData, ClientDelegatingFuture<Boolean> delegatingFuture, ExecutionCallback<Boolean> callback)
protected ClientDelegatingFuture<V> wrapPutAsyncFuture(K key, V value, Data keyData, Data valueData, ClientInvocationFuture invocationFuture, com.hazelcast.client.cache.impl.OneShotExecutionCallback<V> callback)
protected <T> void onGetAndRemoveAsyncInternal(K key, Data keyData, ClientDelegatingFuture<T> delegatingFuture, ExecutionCallback<T> callback)
protected <T> void onReplaceInternalAsync(K key, V value, Data keyData, Data valueData, ClientDelegatingFuture<T> delegatingFuture, ExecutionCallback<T> callback)
protected <T> void onReplaceAndGetAsync(K key, V value, Data keyData, Data valueData, ClientDelegatingFuture<T> delegatingFuture, ExecutionCallback<T> callback)
protected void getAllInternal(Set<? extends K> keys, Collection<Data> dataKeys, javax.cache.expiry.ExpiryPolicy expiryPolicy, List<Object> resultingKeyValuePairs, long startNanos)
public void setExpiryPolicyInternal(Set<? extends K> keys, javax.cache.expiry.ExpiryPolicy expiryPolicy)
protected boolean setExpiryPolicyInternal(K key, javax.cache.expiry.ExpiryPolicy 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)
protected boolean containsKeyInternal(Object key)
containsKeyInternal in class ClientCacheProxy<K,V>protected void loadAllInternal(Set<? extends K> keys, List<Data> dataKeys, boolean replaceExistingValues, javax.cache.integration.CompletionListener completionListener)
loadAllInternal in class ClientCacheProxy<K,V>protected void removeAllKeysInternal(Set<? extends K> keys, Collection<Data> dataKeys, long startNanos)
protected void onRemoveAsyncInternal(Object key, Data keyData, ClientDelegatingFuture future, ExecutionCallback callback)
public void removeAll()
public void clear()
protected Object invokeInternal(Object key, Data epData, Object[] arguments)
invokeInternal in class ClientCacheProxy<K,V>public void close()
protected void postDestroy()
ClientProxypublic String addNearCacheInvalidationListener(EventHandler eventHandler)
public ICompletableFuture<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 ICompletableFuture 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.
key - The key whose associated value is to be returned.javax.cache.Cache#get(K),
ICompletableFuturepublic ICompletableFuture<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 ICompletableFuture 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.
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).javax.cache.Cache#get(K),
ICompletableFuturepublic ICompletableFuture<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.
key - The key whose associated value is to be returned.value - The value to be associated with the specified key.javax.cache.Cache#put(K, V),
ICompletableFuturepublic ICompletableFuture<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.
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).javax.cache.Cache#put(K, V),
ICompletableFuturepublic ICompletableFuture<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.
key - The key that is associated with the specified value.value - The value to which the specified key is associated.javax.cache.Cache#putIfAbsent(K, V),
ICompletableFuturepublic ICompletableFuture<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.
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)javax.cache.Cache#putIfAbsent(K, V),
ICompletableFuturepublic ICompletableFuture<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.
key - The key whose associated value is to be returned.value - The value that is associated with the specified key.javax.cache.Cache#getAndPut(K, V),
ICompletableFuturepublic ICompletableFuture<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.
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).javax.cache.Cache#getAndPut(K, V),
ICompletableFuturepublic ICompletableFuture<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 ICompletableFuture 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.
key - The key whose mapping is to be removed.javax.cache.Cache#remove(K),
ICompletableFuturepublic ICompletableFuture<Boolean> removeAsync(K key, V oldValue)
ICacheThis 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 ICompletableFuture 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.
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.javax.cache.Cache#remove(K, V),
ICompletableFuturepublic ICompletableFuture<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 ICompletableFuture 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.
key - The key to be removed and whose associated value is to be returned.javax.cache.Cache#getAndRemove(K),
ICompletableFuturepublic ICompletableFuture<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.
key - The key whose associated value is to be replaced.value - The new value to be associated with the specified key.javax.cache.Cache#replace(K, V),
ICompletableFuturepublic ICompletableFuture<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.
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)javax.cache.Cache#replace(K, V),
ICompletableFuturepublic ICompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
ICacheThis 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 ICompletableFuture 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.
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.javax.cache.Cache#replace(K, V, V),
ICompletableFuturepublic ICompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy.
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 ICompletableFuture 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.
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).javax.cache.Cache#replace(K, V, V),
ICompletableFuturepublic ICompletableFuture<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.
key - The key whose value is replaced.value - The new value to be associated with the specified key.javax.cache.Cache#getAndReplace(K, V),
ICompletableFuturepublic ICompletableFuture<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.
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)javax.cache.Cache#getAndReplace(K, V),
ICompletableFuturepublic 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.
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).javax.cache.Cache#get(K)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.
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.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).javax.cache.Cache#put(K, V)public V getAndPut(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy,
returning an existing value if one existed.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).javax.cache.Cache#getAndPut(K, V)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.
map - The mappings to be stored in this cache.expiryPolicy - The custom expiry policy for this operation,
a null value is equivalent to Cache.putAll(java.util.Map).Cache.putAll(java.util.Map)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.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.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 otherwiseprotected void setExpiryPolicyInternal(Set<? extends K> keys, javax.cache.expiry.ExpiryPolicy policy, Set<Data> serializedKeys)
public 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.
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).javax.cache.Cache#putIfAbsent(K, V)public boolean replace(K key,
V oldValue,
V newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheExpiryPolicy.
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.
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).javax.cache.Cache#replace(K, V, V)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.
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)javax.cache.Cache#replace(K, V)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.
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).javax.cache.Cache#getAndReplace(K, V)public int size()
ICacheInteger.MAX_VALUE elements, returns Integer.MAX_VALUE.public CacheStatistics getLocalCacheStatistics()
ICachepublic 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 onDestroy()
ClientProxyonDestroy in class ClientProxyprotected ClientInvocationFuture invoke(ClientMessage req, int partitionId, int completionId)
protected ClientInvocationFuture invoke(ClientMessage req, Data keyData, int completionId)
protected <T> T getSafely(Future<T> future)
protected <T> ICompletableFuture<T> getAndRemoveAsyncInternal(K key)
protected <T> ClientDelegatingFuture<T> getAndRemoveSyncInternal(K key)
protected Object removeAsyncInternal(K key, V oldValue, boolean hasOldValue, boolean withCompletionEvent, boolean async)
protected boolean replaceSyncInternal(K key,
V oldValue,
V newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean hasOldValue)
protected <T> ICompletableFuture<T> replaceAsyncInternal(K key, V oldValue, V newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy, boolean hasOldValue, boolean withCompletionEvent, boolean async)
protected <T> ICompletableFuture<T> replaceAndGetAsyncInternal(K key, V oldValue, V newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy, boolean hasOldValue, boolean withCompletionEvent, boolean async)
protected static <T> void addCallback(ClientDelegatingFuture<T> delegatingFuture, ExecutionCallback<T> 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, com.hazelcast.client.cache.impl.OneShotExecutionCallback<V> callback)
protected com.hazelcast.client.cache.impl.OneShotExecutionCallback<V> newStatsCallbackOrNull(boolean isGet)
protected Object putIfAbsentInternal(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy, boolean withCompletionEvent, boolean async)
protected void removeAllInternal()
protected void clearInternal()
protected void addListenerLocally(String regId, javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration, CacheEventListenerAdaptor<K,V> adaptor)
protected String removeListenerLocally(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
protected String getListenerIdLocal(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
protected void closeListeners()
public void countDownCompletionLatch(int countDownLatchId)
countDownCompletionLatch in interface CacheSyncListenerCompleterprotected Integer registerCompletionLatch(Integer countDownLatchId, int count)
protected void deregisterCompletionLatch(Integer countDownLatchId)
protected void waitCompletionLatch(Integer countDownLatchId, ICompletableFuture future) throws ExecutionException
ExecutionExceptionprotected EventHandler createHandler(CacheEventListenerAdaptor<K,V> adaptor)
protected void injectDependencies(Object obj)
protected String getDistributedObjectName()
getDistributedObjectName in class ClientProxyprotected int nextCompletionId()
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 PrefixedDistributedObject@Deprecated public String getNameWithPrefix()
protected <T> T invoke(ClientMessage clientMessage)
invoke in class ClientProxyprotected ClientMessage invoke(ClientMessage clientMessage, Data keyData)
protected void submitLoadAllTask(ClientMessage request, javax.cache.integration.CompletionListener completionListener, List<Data> binaryKeys)
protected <T> ClientDelegatingFuture<T> newDelegatingFuture(ClientInvocationFuture future, ClientMessageDecoder decoder)
protected <T> ClientDelegatingFuture<T> newDelegatingFuture(ClientInvocationFuture future, ClientMessageDecoder decoder, boolean deserializeResponse)
Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.