com.hazelcast.client.cache.impl
Class ClientCacheProxy<K,V>

java.lang.Object
  extended by com.hazelcast.client.cache.impl.ClientCacheProxy<K,V>
Type Parameters:
K - key type
V - value type
All Implemented Interfaces:
ICache<K,V>, CacheSyncListenerCompleter, Closeable, Iterable<javax.cache.Cache.Entry<K,V>>, javax.cache.Cache<K,V>

public class ClientCacheProxy<K,V>
extends Object

ICache implementation for client

This proxy is the implementation of ICache and javax.cache.Cache which is returned by HazelcastClientCacheManager. Represent a cache on client.

This implementation is a thin proxy implementation using hazelcast client infrastructure


Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.cache.Cache
javax.cache.Cache.Entry<K,V>
 
Field Summary
protected  CacheConfig<K,V> cacheConfig
           
protected  ClientContext clientContext
           
protected  ILogger logger
           
protected  String name
           
protected  String nameWithPrefix
           
protected  ClientNearCache<Data,Object> nearCache
           
 
Constructor Summary
ClientCacheProxy(CacheConfig<K,V> cacheConfig, ClientContext clientContext, HazelcastClientCacheManager cacheManager)
           
 
Method Summary
protected  void addListenerLocally(String regId, javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
           
 void clear()
           
protected  void clearInternal()
           
 void close()
           
protected  void closeCacheLoader()
           
protected  void closeListeners()
           
 boolean containsKey(K key)
           
 void countDownCompletionLatch(int id)
           
protected  ICompletableFuture createCompletedFuture(Object value)
           
protected  EventHandler<Object> createHandler(CacheEventListenerAdaptor adaptor)
           
 void deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
           
protected  void deregisterCompletionLatch(Integer countDownLatchId)
           
 void destroy()
           
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.
 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>>
C
getConfiguration(Class<C> clazz)
           
 CacheStatistics getLocalCacheStatistics()
           
 String getName()
           
 String getNameWithPrefix()
           
protected
<T> T
getSafely(Future<T> future)
           
protected  void invalidateNearCache(Data key)
           
protected
<T> T
invoke(ClientRequest req)
           
protected
<T> ICompletableFuture<T>
invoke(ClientRequest req, Data keyData, boolean completionOperation)
           
<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()
           
 Iterator<javax.cache.Cache.Entry<K,V>> iterator()
           
 void loadAll(Set<? extends K> keys, boolean replaceExistingValues, javax.cache.integration.CompletionListener completionListener)
           
 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.
protected
<T> ICompletableFuture<T>
putAsyncInternal(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy, boolean isGet, boolean withCompletionEvent)
           
 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 for the specified key defined.
 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 for the specified key defined.
 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 for the specified key defined.
protected  ICompletableFuture<Boolean> putIfAbsentAsyncInternal(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy, boolean withCompletionEvent)
           
 void registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
           
protected  Integer registerCompletionLatch(int count)
           
 boolean remove(K key)
           
 boolean remove(K key, V oldValue)
           
 void removeAll()
           
 void removeAll(Set<? extends K> keys)
           
protected  void removeAllInternal(Set<? extends K> keys, boolean isRemoveAll)
           
 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 isGet, boolean withCompletionEvent)
           
protected  String removeListenerLocally(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
           
 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.
 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 isGet, boolean withCompletionEvent)
           
 int size()
          Total entry count.
protected  void storeInNearCache(Data key, Data valueData, V value)
           
protected  void submitLoadAllTask(CacheLoadAllRequest request, javax.cache.integration.CompletionListener completionListener)
           
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 validateCacheLoader(javax.cache.integration.CompletionListener completionListener)
           
protected  void waitCompletionLatch(Integer countDownLatchId)
           
protected  void waitCompletionLatch(Integer countDownLatchId, int offset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.hazelcast.cache.ICache
destroy, isDestroyed
 
Methods inherited from interface javax.cache.Cache
close, isClosed
 

Field Detail

logger

protected final ILogger logger

nearCache

protected final ClientNearCache<Data,Object> nearCache

clientContext

protected final ClientContext clientContext

cacheConfig

protected final CacheConfig<K,V> cacheConfig

name

protected final String name

nameWithPrefix

protected final String nameWithPrefix
Constructor Detail

ClientCacheProxy

public ClientCacheProxy(CacheConfig<K,V> cacheConfig,
                        ClientContext clientContext,
                        HazelcastClientCacheManager cacheManager)
Method Detail

get

public V get(K key)

getAll

public Map<K,V> getAll(Set<? extends K> keys)

containsKey

public boolean containsKey(K key)

loadAll

public void loadAll(Set<? extends K> keys,
                    boolean replaceExistingValues,
                    javax.cache.integration.CompletionListener completionListener)

put

public void put(K key,
                V value)

getAndPut

public V getAndPut(K key,
                   V value)

putAll

public void putAll(Map<? extends K,? extends V> map)

putIfAbsent

public boolean putIfAbsent(K key,
                           V value)

remove

public boolean remove(K key)

remove

public boolean remove(K key,
                      V oldValue)

getAndRemove

public V getAndRemove(K key)

replace

public boolean replace(K key,
                       V oldValue,
                       V newValue)

replace

public boolean replace(K key,
                       V value)

getAndReplace

public V getAndReplace(K key,
                       V value)

removeAll

public void removeAll(Set<? extends K> keys)

removeAll

public void removeAll()

clear

public void clear()

getConfiguration

public <C extends javax.cache.configuration.Configuration<K,V>> C getConfiguration(Class<C> clazz)

invoke

public <T> T invoke(K key,
                    javax.cache.processor.EntryProcessor<K,V,T> entryProcessor,
                    Object... arguments)
         throws javax.cache.processor.EntryProcessorException
Throws:
javax.cache.processor.EntryProcessorException

invokeAll

public <T> Map<K,javax.cache.processor.EntryProcessorResult<T>> invokeAll(Set<? extends K> keys,
                                                                          javax.cache.processor.EntryProcessor<K,V,T> entryProcessor,
                                                                          Object... arguments)

getName

public String getName()

getCacheManager

public javax.cache.CacheManager getCacheManager()

unwrap

public <T> T unwrap(Class<T> clazz)

registerCacheEntryListener

public void registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)

deregisterCacheEntryListener

public void deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)

updateCacheListenerConfigOnOtherNodes

protected void updateCacheListenerConfigOnOtherNodes(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration,
                                                     boolean isRegister)

iterator

public Iterator<javax.cache.Cache.Entry<K,V>> iterator()

getAsync

public ICompletableFuture<V> getAsync(K key)
Description copied from interface: ICache
Asynchronously retrieves the mapped value of the given key using a custom 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.

Specified by:
getAsync in interface ICache<K,V>
Parameters:
key - the key whose associated value is to be returned
Returns:
ICompletableFuture to retrieve the value assigned to the given key
See Also:
javax.cache.Cache#get(K), ICompletableFuture

getAsync

public ICompletableFuture<V> getAsync(K key,
                                      javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Asynchronously gets an entry from cache using a custom 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.

Specified by:
getAsync in interface ICache<K,V>
Parameters:
key - the key whose associated value is to be returned
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to ICache.getAsync(Object)
Returns:
ICompletableFuture to retrieve the value assigned to the given key
See Also:
javax.cache.Cache#get(K), ICompletableFuture

putAsync

public ICompletableFuture<Void> putAsync(K key,
                                         V value)
Description copied from interface: ICache
Asynchronously associates the specified value with the specified key in the cache.

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.

Specified by:
putAsync in interface ICache<K,V>
Parameters:
key - the key whose associated value is to be returned
value - the value to be associated with the specified key
Returns:
ICompletableFuture to get notified when the operation succeed
See Also:
javax.cache.Cache#put(K,V), ICompletableFuture

putAsync

public ICompletableFuture<Void> putAsync(K key,
                                         V value,
                                         javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Asynchronously associates the specified value with the specified key in the cache using a custom 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.

Specified by:
putAsync in interface ICache<K,V>
Parameters:
key - the key whose associated value is to be returned
value - the value to be associated with the specified key
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to ICache.putAsync(Object, Object)
Returns:
ICompletableFuture to get notified when the operation succeed
See Also:
javax.cache.Cache#put(K,V), ICompletableFuture

putIfAbsentAsync

public ICompletableFuture<Boolean> putIfAbsentAsync(K key,
                                                    V value)
Description copied from interface: ICache
Asynchronously associates the specified key with the given value if and only if there is not yet a mapping for the specified key defined.

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.

Specified by:
putIfAbsentAsync in interface ICache<K,V>
Parameters:
key - the key with which the specified value is to be associated
value - the value to be associated with the specified key
Returns:
ICompletableFuture to retrieve if a previous value was assigned with the key
See Also:
javax.cache.Cache#putIfAbsent(K,V), ICompletableFuture

putIfAbsentAsync

public ICompletableFuture<Boolean> putIfAbsentAsync(K key,
                                                    V value,
                                                    javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Asynchronously associates the specified key with the given value if and only if there is not yet a mapping for the specified key defined. using a custom 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.

Specified by:
putIfAbsentAsync in interface ICache<K,V>
Parameters:
key - the key with which the specified value is to be associated
value - the value to be associated with the specified key
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to ICache.putIfAbsentAsync(Object, Object, javax.cache.expiry.ExpiryPolicy)
Returns:
ICompletableFuture to retrieve if a previous value was assigned with the key
See Also:
javax.cache.Cache#putIfAbsent(K,V), ICompletableFuture

getAndPutAsync

public ICompletableFuture<V> getAndPutAsync(K key,
                                            V value)
Description copied from interface: ICache
Asynchronously associates the specified value with the specified key in this cache, returning an existing value if one existed.

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.

Specified by:
getAndPutAsync in interface ICache<K,V>
Parameters:
key - the key whose associated value is to be returned
value - the value to be associated with the specified key
Returns:
ICompletableFuture to retrieve a possible previously assigned value for the given key
See Also:
javax.cache.Cache#getAndPut(K,V), ICompletableFuture

getAndPutAsync

public ICompletableFuture<V> getAndPutAsync(K key,
                                            V value,
                                            javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Asynchronously associates the specified value with the specified key in this cache, returning an existing value if one existed using a custom 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.

Specified by:
getAndPutAsync in interface ICache<K,V>
Parameters:
key - the key whose associated value is to be returned.
value - the value to be associated with the specified key.
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to ICache.getAndPutAsync(Object, Object, javax.cache.expiry.ExpiryPolicy)
Returns:
ICompletableFuture to retrieve a possible previously assigned value for the given key
See Also:
javax.cache.Cache#getAndPut(K,V), ICompletableFuture

removeAsync

public ICompletableFuture<Boolean> removeAsync(K key)
Description copied from interface: ICache
Asynchronously removes the mapping for a key from this cache if it is present.

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.

Specified by:
removeAsync in interface ICache<K,V>
Parameters:
key - the key whose associated value is to be returned
Returns:
ICompletableFuture to retrieve if value could be removed or not
See Also:
javax.cache.Cache#remove(K), ICompletableFuture

removeAsync

public ICompletableFuture<Boolean> removeAsync(K key,
                                               V oldValue)
Description copied from interface: ICache
Asynchronously removes the mapping for the given key if and only if the currently mapped value equals to the value of oldValue.

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.

Specified by:
removeAsync in interface ICache<K,V>
Parameters:
key - the key whose associated value is to be returned.
oldValue - the value expected to be associated with the specified key.
Returns:
ICompletableFuture to retrieve if value could be removed or not
See Also:
javax.cache.Cache#remove(K,V), ICompletableFuture

getAndRemoveAsync

public ICompletableFuture<V> getAndRemoveAsync(K key)
Description copied from interface: ICache
Asynchronously removes the entry for a key and returns the previously assigned value or null if no value was assigned.

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.

Specified by:
getAndRemoveAsync in interface ICache<K,V>
Parameters:
key - the key whose associated value is to be returned
Returns:
ICompletableFuture to retrieve a possible previously assigned value for the removed key
See Also:
javax.cache.Cache#getAndRemove(K), ICompletableFuture

replaceAsync

public ICompletableFuture<Boolean> replaceAsync(K key,
                                                V value)
Description copied from interface: ICache
Asynchronously replaces the assigned value of the given key by the specified 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.

Specified by:
replaceAsync in interface ICache<K,V>
Parameters:
key - the key whose associated value is to be returned
value - the value to be associated with the specified key
Returns:
ICompletableFuture to get notified if the operation succeed or not
See Also:
javax.cache.Cache#replace(K,V), ICompletableFuture

replaceAsync

public ICompletableFuture<Boolean> replaceAsync(K key,
                                                V value,
                                                javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Asynchronously replaces the assigned value of the given key by the specified value using a custom 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.

Specified by:
replaceAsync in interface ICache<K,V>
Parameters:
key - the key with which the specified value is associated
value - the value to be associated with the specified key
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to ICache.replaceAsync(Object, Object)
Returns:
ICompletableFuture to get notified if the operation succeed or not
See Also:
javax.cache.Cache#replace(K,V), ICompletableFuture

replaceAsync

public ICompletableFuture<Boolean> replaceAsync(K key,
                                                V oldValue,
                                                V newValue)
Description copied from interface: ICache
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.

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.

Specified by:
replaceAsync in interface ICache<K,V>
Parameters:
key - the key with which the specified value is associated
oldValue - the value expected to be associated with the specified key
newValue - the value to be associated with the specified key
Returns:
ICompletableFuture to get notified if the operation succeed or not
See Also:
javax.cache.Cache#replace(K,V,V), ICompletableFuture

replaceAsync

public ICompletableFuture<Boolean> replaceAsync(K key,
                                                V oldValue,
                                                V newValue,
                                                javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
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.

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.

Specified by:
replaceAsync in interface ICache<K,V>
Parameters:
key - the key with which the specified value is associated
oldValue - the value expected to be associated with the specified key
newValue - the value to be associated with the specified key
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to ICache.replaceAsync(Object, Object, Object)
Returns:
ICompletableFuture to get notified if the operation succeed or not
See Also:
javax.cache.Cache#replace(K,V,V), ICompletableFuture

getAndReplaceAsync

public ICompletableFuture<V> getAndReplaceAsync(K key,
                                                V value)
Description copied from interface: ICache
Asynchronously replaces the assigned value of the given key by the specified value 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.

Specified by:
getAndReplaceAsync in interface ICache<K,V>
Parameters:
key - the key with which the specified value is associated
value - the value to be associated with the specified key
Returns:
ICompletableFuture to retrieve a possible previously assigned value for the given key
See Also:
javax.cache.Cache#getAndReplace(K,V), ICompletableFuture

getAndReplaceAsync

public ICompletableFuture<V> getAndReplaceAsync(K key,
                                                V value,
                                                javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Asynchronously replaces the assigned value of the given key by the specified value using a custom 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.

Specified by:
getAndReplaceAsync in interface ICache<K,V>
Parameters:
key - the key with which the specified value is associated
value - the value to be associated with the specified key
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to Cache.getAndReplace(Object, Object)
Returns:
ICompletableFuture to retrieve a possible previously assigned value for the given key
See Also:
javax.cache.Cache#getAndReplace(K,V), ICompletableFuture

get

public V get(K key,
             javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Retrieves the mapped value of the given key using a custom 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.

Specified by:
get in interface ICache<K,V>
Parameters:
key - the key whose associated value is to be returned
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to Cache.get(Object)
Returns:
returns the value assigned to the given key or null if not assigned
See Also:
javax.cache.Cache#get(K)

getAll

public Map<K,V> getAll(Set<? extends K> keys,
                       javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
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.

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.

Specified by:
getAll in interface ICache<K,V>
Parameters:
keys - the keys whose associated values are to be returned
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to Cache.getAll(java.util.Set)
Returns:
A map of entries that were found for the given keys. Keys not found in the cache are not in the returned map.
See Also:
Cache.getAll(java.util.Set)

put

public void put(K key,
                V value,
                javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Associates the specified value with the specified key in the cache using a custom ExpiryPolicy.

Specified by:
put in interface ICache<K,V>
Parameters:
key - the key with which the specified value is to be associated
value - value to be associated with the specified key
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to Cache.put(Object, Object)
See Also:
javax.cache.Cache#put(K,V)

getAndPut

public V getAndPut(K key,
                   V value,
                   javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Associates the specified value with the specified key in this cache using a custom ExpiryPolicy, returning an existing value if one existed.

Specified by:
getAndPut in interface ICache<K,V>
Parameters:
key - the key with which the specified value is to be associated
value - the value to be associated with the specified key
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to Cache.getAndPut(Object, Object)
Returns:
returns the value previously assigned to the given key or null if not assigned
See Also:
javax.cache.Cache#getAndPut(K,V)

putAll

public void putAll(Map<? extends K,? extends V> map,
                   javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Copies all of the entries from the given map to the cache using a custom 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.

Specified by:
putAll in interface ICache<K,V>
Parameters:
map - the mappings to be stored in this cache
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to Cache.putAll(java.util.Map)
See Also:
Cache.putAll(java.util.Map)

putIfAbsent

public boolean putIfAbsent(K key,
                           V value,
                           javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Associates the specified key with the given value if and only if there is not yet a mapping for the specified key defined.

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.

Specified by:
putIfAbsent in interface ICache<K,V>
Parameters:
key - the key with which the specified value is to be associated
value - the value to be associated with the specified key
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to Cache.putIfAbsent(Object, Object)
Returns:
true if a value was set
See Also:
javax.cache.Cache#putIfAbsent(K,V)

replace

public boolean replace(K key,
                       V oldValue,
                       V newValue,
                       javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
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.

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.

Specified by:
replace in interface ICache<K,V>
Parameters:
key - the key with which the specified value is associated
oldValue - the value expected to be associated with the specified key
newValue - the value to be associated with the specified key
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to Cache.replace(Object, Object, Object)
Returns:
true if a value was replaced
See Also:
javax.cache.Cache#replace(K,V,V)

replace

public boolean replace(K key,
                       V value,
                       javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Atomically replaces the assigned value of the given key by the specified value using a custom 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.

Specified by:
replace in interface ICache<K,V>
Parameters:
key - the key with which the specified value is associated
value - the value to be associated with the specified key
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to Cache.replace(Object, Object)
Returns:
true if a value was replaced
See Also:
javax.cache.Cache#replace(K,V)

getAndReplace

public V getAndReplace(K key,
                       V value,
                       javax.cache.expiry.ExpiryPolicy expiryPolicy)
Description copied from interface: ICache
Atomically replaces the assigned value of the given key by the specified value using a custom 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.

Specified by:
getAndReplace in interface ICache<K,V>
Parameters:
key - the key with which the specified value is associated
value - the value to be associated with the specified key
expiryPolicy - custom expiry policy for this operation, a null value is equivalent to Cache.getAndReplace(Object, Object)
Returns:
the value previously assigned to the given key
See Also:
javax.cache.Cache#getAndReplace(K,V)

size

public int size()
Description copied from interface: ICache
Total entry count.

Specified by:
size in interface ICache<K,V>
Returns:
total entry count

getLocalCacheStatistics

public CacheStatistics getLocalCacheStatistics()
Specified by:
getLocalCacheStatistics in interface ICache<K,V>

invoke

protected <T> ICompletableFuture<T> invoke(ClientRequest req,
                                           Data keyData,
                                           boolean completionOperation)

getSafely

protected <T> T getSafely(Future<T> future)

removeAsyncInternal

protected <T> ICompletableFuture<T> removeAsyncInternal(K key,
                                                        V oldValue,
                                                        boolean hasOldValue,
                                                        boolean isGet,
                                                        boolean withCompletionEvent)

replaceAsyncInternal

protected <T> ICompletableFuture<T> replaceAsyncInternal(K key,
                                                         V oldValue,
                                                         V newValue,
                                                         javax.cache.expiry.ExpiryPolicy expiryPolicy,
                                                         boolean hasOldValue,
                                                         boolean isGet,
                                                         boolean withCompletionEvent)

putAsyncInternal

protected <T> ICompletableFuture<T> putAsyncInternal(K key,
                                                     V value,
                                                     javax.cache.expiry.ExpiryPolicy expiryPolicy,
                                                     boolean isGet,
                                                     boolean withCompletionEvent)

putIfAbsentAsyncInternal

protected ICompletableFuture<Boolean> putIfAbsentAsyncInternal(K key,
                                                               V value,
                                                               javax.cache.expiry.ExpiryPolicy expiryPolicy,
                                                               boolean withCompletionEvent)

removeAllInternal

protected void removeAllInternal(Set<? extends K> keys,
                                 boolean isRemoveAll)

clearInternal

protected void clearInternal()

storeInNearCache

protected void storeInNearCache(Data key,
                                Data valueData,
                                V value)

invalidateNearCache

protected void invalidateNearCache(Data key)

addListenerLocally

protected void addListenerLocally(String regId,
                                  javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)

removeListenerLocally

protected String removeListenerLocally(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)

closeListeners

protected void closeListeners()

countDownCompletionLatch

public void countDownCompletionLatch(int id)
Specified by:
countDownCompletionLatch in interface CacheSyncListenerCompleter

registerCompletionLatch

protected Integer registerCompletionLatch(int count)

deregisterCompletionLatch

protected void deregisterCompletionLatch(Integer countDownLatchId)

waitCompletionLatch

protected void waitCompletionLatch(Integer countDownLatchId)

waitCompletionLatch

protected void waitCompletionLatch(Integer countDownLatchId,
                                   int offset)

createHandler

protected EventHandler<Object> createHandler(CacheEventListenerAdaptor adaptor)

createCompletedFuture

protected ICompletableFuture createCompletedFuture(Object value)

ensureOpen

protected void ensureOpen()

close

public void close()

destroy

public void destroy()

isClosed

public boolean isClosed()

isDestroyed

public boolean isDestroyed()

getNameWithPrefix

public String getNameWithPrefix()

toObject

protected <T> T toObject(Object data)

toData

protected Data toData(Object o)

invoke

protected <T> T invoke(ClientRequest req)

validateCacheLoader

protected void validateCacheLoader(javax.cache.integration.CompletionListener completionListener)

closeCacheLoader

protected void closeCacheLoader()

submitLoadAllTask

protected void submitLoadAllTask(CacheLoadAllRequest request,
                                 javax.cache.integration.CompletionListener completionListener)


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.