K
- key typeV
- value typepublic class ClientCacheProxy<K,V> extends ClientProxy
Modifier and Type | Field and Description |
---|---|
protected CacheConfig<K,V> |
cacheConfig |
protected HazelcastClientCacheManager |
cacheManager |
protected boolean |
cacheOnUpdate |
protected ClientContext |
clientContext |
protected ILogger |
logger |
protected String |
name |
protected String |
nameWithPrefix |
protected NearCache<Data,Object> |
nearCache |
protected NearCacheManager |
nearCacheManager |
protected String |
nearCacheMembershipRegistrationId |
protected ClientCacheStatisticsImpl |
statistics |
protected boolean |
statisticsEnabled |
Constructor and Description |
---|
ClientCacheProxy(CacheConfig<K,V> cacheConfig) |
Modifier and Type | Method and Description |
---|---|
protected void |
addListenerLocally(String regId,
javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration) |
String |
addPartitionLostListener(CachePartitionLostListener listener)
Adds a CachePartitionLostListener.
|
void |
clear() |
protected void |
clearInternal() |
void |
close() |
protected void |
closeListeners() |
boolean |
containsKey(K key) |
void |
countDownCompletionLatch(int countDownLatchId) |
protected ICompletableFuture |
createCompletedFuture(Object value) |
protected EventHandler |
createHandler(CacheEventListenerAdaptor<K,V> adaptor) |
void |
deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration) |
protected void |
deregisterCompletionLatch(Integer countDownLatchId) |
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. |
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. |
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 . |
V |
getAndRemove(K key) |
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,
boolean withCompletionEvent,
boolean async) |
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. |
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 . |
javax.cache.CacheManager |
getCacheManager() |
<C extends javax.cache.configuration.Configuration<K,V>> |
getConfiguration(Class<C> clazz) |
protected String |
getDistributedObjectName() |
protected Object |
getFromNearCache(Data keyData,
boolean async) |
protected Object |
getInternal(K key,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean async) |
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 void |
handleStatisticsOnGet(long start,
Object response) |
protected void |
handleStatisticsOnPut(boolean isGet,
long start,
Object response) |
protected void |
handleStatisticsOnPutIfAbsent(long start,
boolean saved) |
protected void |
handleStatisticsOnRemove(boolean isGet,
long start,
Object response) |
protected void |
handleStatisticsOnReplace(boolean isGet,
long start,
Object response) |
protected void |
injectDependencies(Object obj) |
protected void |
invalidateNearCache(Data key) |
protected ClientMessage |
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) |
<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) |
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) |
void |
loadAll(Set<? extends K> keys,
boolean replaceExistingValues,
javax.cache.integration.CompletionListener completionListener) |
protected int |
nextCompletionId() |
protected void |
onDestroy()
Called before proxy is destroyed.
|
protected void |
onInitialize()
Called when proxy is created.
|
protected void |
onLoadAll(Set<Data> keys,
Object response,
long start,
long end) |
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 . |
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 . |
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.
|
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 Object |
putInternal(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean isGet,
boolean withCompletionEvent,
boolean async) |
void |
registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration) |
protected Integer |
registerCompletionLatch(Integer countDownLatchId,
int count) |
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) |
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 <T> ICompletableFuture<T> |
removeAsyncInternal(K key,
V oldValue,
boolean hasOldValue,
boolean withCompletionEvent,
boolean async) |
protected String |
removeListenerLocally(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration) |
boolean |
removePartitionLostListener(String 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> 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> |
replaceInternal(K key,
V oldValue,
V newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
boolean hasOldValue,
boolean withCompletionEvent,
boolean async) |
int |
size()
Total entry count.
|
protected void |
storeInNearCache(Data key,
Data valueData,
V value) |
protected void |
submitLoadAllTask(ClientMessage request,
javax.cache.integration.CompletionListener completionListener,
Set<Data> keys) |
protected Data |
toData(Object o) |
protected <T> T |
toObject(Object data) |
<T> T |
unwrap(Class<T> clazz) |
protected void |
updateCacheListenerConfigOnOtherNodes(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration,
boolean isRegister) |
protected void |
waitCompletionLatch(Integer countDownLatchId,
ICompletableFuture future) |
deregisterListener, destroy, equals, getClient, getContext, getId, getName, getPartitionKey, getSerializationService, getServiceName, hashCode, invoke, invokeOnPartition, invokeOnPartitionInterruptibly, onShutdown, registerListener, setContext
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
open
destroy, isDestroyed
getPrefixedName
getName, getPartitionKey, getServiceName
protected HazelcastClientCacheManager cacheManager
protected NearCacheManager nearCacheManager
protected String nearCacheMembershipRegistrationId
protected ClientCacheStatisticsImpl statistics
protected boolean statisticsEnabled
protected boolean cacheOnUpdate
protected ClientContext clientContext
protected final CacheConfig<K,V> cacheConfig
protected final String name
protected final String nameWithPrefix
protected ILogger logger
public ClientCacheProxy(CacheConfig<K,V> cacheConfig)
public NearCache getNearCache()
public boolean containsKey(K key)
public void loadAll(Set<? extends K> keys, boolean replaceExistingValues, javax.cache.integration.CompletionListener completionListener)
public boolean remove(K key)
public void removeAll()
public void clear()
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
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 javax.cache.CacheManager getCacheManager()
public <T> T unwrap(Class<T> clazz)
public void registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
public void deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
protected void updateCacheListenerConfigOnOtherNodes(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration, boolean isRegister)
public Iterator<javax.cache.Cache.Entry<K,V>> iterator(int fetchSize)
ICache
Creates 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.fetchSize
- size for fetching keys in bulk.
This size can be thought of as page size for iteration.
But notice that at every fetch, only keys are retrieved, not values.
Values are retrieved on each iterate.Cache.iterator()
public Iterator<javax.cache.Cache.Entry<K,V>> iterator(int fetchSize, int partitionId, boolean prefetchValues)
public String addPartitionLostListener(CachePartitionLostListener listener)
ICache
ICache.removePartitionLostListener(String)
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.listener
- the added CachePartitionLostListener.ICache.removePartitionLostListener(String)
public boolean removePartitionLostListener(String id)
ICache
id
- ID of registered listener.protected Object getInternal(K key, javax.cache.expiry.ExpiryPolicy expiryPolicy, boolean async)
protected void handleStatisticsOnGet(long start, Object response)
public ICompletableFuture<V> getAsync(K key)
ICache
ExpiryPolicy
. 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
.
getAsync
in interface ICache<K,V>
key
- The key whose associated value is to be returned.javax.cache.Cache#get(K)
,
ICompletableFuture
public ICompletableFuture<V> getAsync(K key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
ExpiryPolicy
.
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
.
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)
.javax.cache.Cache#get(K)
,
ICompletableFuture
public ICompletableFuture<Void> putAsync(K key, V value)
ICache
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.javax.cache.Cache#put(K,V)
,
ICompletableFuture
public ICompletableFuture<Void> putAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
ExpiryPolicy
.
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)
.javax.cache.Cache#put(K,V)
,
ICompletableFuture
public ICompletableFuture<Boolean> putIfAbsentAsync(K key, V value)
ICache
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.javax.cache.Cache#putIfAbsent(K,V)
,
ICompletableFuture
public ICompletableFuture<Boolean> putIfAbsentAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
ExpiryPolicy
.
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)
javax.cache.Cache#putIfAbsent(K,V)
,
ICompletableFuture
public 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.
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.javax.cache.Cache#getAndPut(K,V)
,
ICompletableFuture
public ICompletableFuture<V> getAndPutAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
ExpiryPolicy
.
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)
.javax.cache.Cache#getAndPut(K,V)
,
ICompletableFuture
public 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
.
removeAsync
in interface ICache<K,V>
key
- The key whose mapping is to be removed.javax.cache.Cache#remove(K)
,
ICompletableFuture
public ICompletableFuture<Boolean> removeAsync(K key, V oldValue)
ICache
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 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
.
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.javax.cache.Cache#remove(K,V)
,
ICompletableFuture
public 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
.
getAndRemoveAsync
in interface ICache<K,V>
key
- The key to be removed and whose associated value is to be returned.javax.cache.Cache#getAndRemove(K)
,
ICompletableFuture
public 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.
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.javax.cache.Cache#replace(K,V)
,
ICompletableFuture
public ICompletableFuture<Boolean> replaceAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
ExpiryPolicy
.
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)
javax.cache.Cache#replace(K,V)
,
ICompletableFuture
public ICompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
ICache
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
.
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.javax.cache.Cache#replace(K,V,V)
,
ICompletableFuture
public ICompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
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 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
.
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)
.javax.cache.Cache#replace(K,V,V)
,
ICompletableFuture
public 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.
getAndReplaceAsync
in interface ICache<K,V>
key
- The key whose value is replaced.value
- The new value to be associated with the specified key.javax.cache.Cache#getAndReplace(K,V)
,
ICompletableFuture
public ICompletableFuture<V> getAndReplaceAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
ExpiryPolicy
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)
javax.cache.Cache#getAndReplace(K,V)
,
ICompletableFuture
public V get(K key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
ExpiryPolicy
.
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)
.javax.cache.Cache#get(K)
public Map<K,V> getAll(Set<? extends K> keys, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
Map
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)
ICache
ExpiryPolicy
.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)
.javax.cache.Cache#put(K,V)
public V getAndPut(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
ExpiryPolicy
,
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)
.javax.cache.Cache#getAndPut(K,V)
public void putAll(Map<? extends K,? extends V> map, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
ExpiryPolicy
.
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 boolean putIfAbsent(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
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.
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)
.javax.cache.Cache#putIfAbsent(K,V)
public boolean replace(K key, V oldValue, V newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
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)
.javax.cache.Cache#replace(K,V,V)
public boolean replace(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
ExpiryPolicy
.
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)
javax.cache.Cache#replace(K,V)
public V getAndReplace(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICache
ExpiryPolicy
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)
.javax.cache.Cache#getAndReplace(K,V)
public int size()
ICache
public CacheStatistics getLocalCacheStatistics()
ICache
getLocalCacheStatistics
in interface ICache<K,V>
protected void onInitialize()
ClientProxy
protected void postDestroy()
ClientProxy
postDestroy
in class ClientProxy
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in interface javax.cache.Cache<K,V>
protected void onDestroy()
ClientProxy
onDestroy
in class ClientProxy
protected 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, boolean withCompletionEvent, boolean async)
protected <T> ICompletableFuture<T> removeAsyncInternal(K key, V oldValue, boolean hasOldValue, boolean withCompletionEvent, boolean async)
protected void handleStatisticsOnRemove(boolean isGet, long start, Object response)
protected <T> ICompletableFuture<T> replaceInternal(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 void handleStatisticsOnReplace(boolean isGet, long start, Object response)
protected Object putInternal(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy, boolean isGet, boolean withCompletionEvent, boolean async)
protected void handleStatisticsOnPut(boolean isGet, long start, Object response)
protected Object putIfAbsentInternal(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy, boolean withCompletionEvent, boolean async)
protected void handleStatisticsOnPutIfAbsent(long start, boolean saved)
protected void removeAllKeysInternal(Set<? extends K> keys)
protected void removeAllInternal()
protected void clearInternal()
protected void invalidateNearCache(Data key)
protected void addListenerLocally(String regId, javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
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 CacheSyncListenerCompleter
protected Integer registerCompletionLatch(Integer countDownLatchId, int count)
protected void deregisterCompletionLatch(Integer countDownLatchId)
protected void waitCompletionLatch(Integer countDownLatchId, ICompletableFuture future) throws ExecutionException
ExecutionException
protected EventHandler createHandler(CacheEventListenerAdaptor<K,V> adaptor)
protected ICompletableFuture createCompletedFuture(Object value)
protected void injectDependencies(Object obj)
protected String getDistributedObjectName()
getDistributedObjectName
in class ClientProxy
protected int nextCompletionId()
protected void ensureOpen()
protected boolean preDestroy()
ClientProxy
preDestroy
in class ClientProxy
true
if destroy should be done, otherwise false
public boolean isClosed()
isClosed
in interface javax.cache.Cache<K,V>
public boolean isDestroyed()
ICache
isDestroyed
in interface ICache<K,V>
true
if this Cache instance is destroyed; false
if it is still open.public void open()
ICacheInternal
open
in interface ICacheInternal<K,V>
public String getPrefixedName()
PrefixedDistributedObject
getPrefixedName
in interface PrefixedDistributedObject
@Deprecated public String getNameWithPrefix()
protected <T> T toObject(Object data)
toObject
in class ClientProxy
protected Data toData(Object o)
toData
in class ClientProxy
protected ClientMessage invoke(ClientMessage clientMessage)
invoke
in class ClientProxy
protected ClientMessage invoke(ClientMessage clientMessage, Data keyData)
protected void submitLoadAllTask(ClientMessage request, javax.cache.integration.CompletionListener completionListener, Set<Data> keys)
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.