K - the type of key.V - the type of value.public interface ICache<K,V>
extends javax.cache.Cache<K,V>
Cache extension
Hazelcast provides extension methods to Cache.
There are three set of extensions:
size().
A method ending with Async is the asynchronous version of that method (for example #getAsync(K),
#replaceAsync(K,V) ).
These methods return a Future where you can get the result or wait for the operation to be completed.
ICache<String , SessionData> icache = cache.unwrap( ICache.class );
Future<SessionData> future = icache.getAsync("key-1" ) ;
SessionData sessionData = future.get();
This interface can be accessed through Cache.unwrap(Class).
Cache| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Closes the cache, clears the internal content and releases any resource.
|
V |
get(K key,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Gets a key with custom expiry policy.
|
Map<K,V> |
getAll(Set<? extends K> keys,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
getAll operation with custom expiry policy.
|
V |
getAndPut(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
getAndPut operation with custom expiry policy.
|
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 expiry policy.
|
ICompletableFuture<V> |
getAndRemoveAsync(K key)
Asynchronously removes the entry for a key returning the removed value if one existed.
|
V |
getAndReplace(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
getAndReplace operation with custom expiry policy.
|
ICompletableFuture<V> |
getAndReplaceAsync(K key,
V value)
Asynchronously replaces the entry for a key only if it is currently mapped to some value.
|
ICompletableFuture<V> |
getAndReplaceAsync(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Asynchronously replaces the entry for a key only if it is currently mapped to some value
using custom expiry policy.
|
ICompletableFuture<V> |
getAsync(K key)
Asynchronously gets an entry from cache.
|
ICompletableFuture<V> |
getAsync(K key,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Asynchronously gets an entry from cache with a provided expiry policy.
|
CacheStatistics |
getLocalCacheStatistics()
Directly access to local Cache Statistics.
|
void |
put(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
put operation with custom expiry policy.
|
void |
putAll(Map<? extends K,? extends V> map,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
putAll operation with custom expiry policy.
|
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 expiry policy.
|
boolean |
putIfAbsent(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
putIfAbsent operation with custom expiry policy.
|
ICompletableFuture<Boolean> |
putIfAbsentAsync(K key,
V value)
Asynchronously associates the specified value with the specified key in the cache if not already exist.
|
ICompletableFuture<Boolean> |
putIfAbsentAsync(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Asynchronously associates the specified value with the specified key in the cache if not already exist,
using a custom expiry policy.
|
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 a key only if it is currently mapped to the
given value.
|
boolean |
replace(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
replace operation with custom expiry policy.
|
boolean |
replace(K key,
V oldValue,
V newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
replace operation with custom expiry policy.
|
ICompletableFuture<Boolean> |
replaceAsync(K key,
V value)
Asynchronously replaces the entry for a key.
|
ICompletableFuture<Boolean> |
replaceAsync(K key,
V value,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Asynchronously replaces the entry for a key only if it is currently mapped to some
value.
|
ICompletableFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue)
Asynchronously replaces the entry for a key only if it is currently mapped to a
given value.
|
ICompletableFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Asynchronously replaces the entry for a key only if it is currently mapped to a
given value using custom expiry policy.
|
int |
size()
Total entry count.
|
clear, close, containsKey, deregisterCacheEntryListener, get, getAll, getAndPut, getAndRemove, getAndReplace, getCacheManager, getConfiguration, getName, invoke, invokeAll, isClosed, iterator, loadAll, put, putAll, putIfAbsent, registerCacheEntryListener, remove, remove, removeAll, removeAll, replace, replace, unwrapICompletableFuture<V> getAsync(K key)
key - the key whose associated value is to be returned.javax.cache.Cache#get(K),
ICompletableFutureICompletableFuture<V> getAsync(K key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
key - the key whose associated value is to be returned.expiryPolicy - custom expiry policy for this operation.javax.cache.Cache#get(K),
ICompletableFutureICompletableFuture<Void> putAsync(K key, V value)
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),
ICompletableFutureICompletableFuture<Void> putAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.javax.cache.Cache#put(K,V),
ICompletableFutureICompletableFuture<Boolean> putIfAbsentAsync(K key, V value)
key - the key with which the specified value is to be associated.value - the value to be associated with the specified key.javax.cache.Cache#putIfAbsent(K,V),
ICompletableFutureICompletableFuture<Boolean> putIfAbsentAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.javax.cache.Cache#putIfAbsent(K,V),
ICompletableFutureICompletableFuture<V> getAndPutAsync(K key, V value)
key - the key whose associated value is to be returned.value - the value to be associated with the specified key.javax.cache.Cache#getAndPut(K,V),
ICompletableFutureICompletableFuture<V> getAndPutAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.javax.cache.Cache#getAndPut(K,V),
ICompletableFutureICompletableFuture<Boolean> removeAsync(K key)
key - the key whose associated value is to be returned.javax.cache.Cache#remove(K),
ICompletableFutureICompletableFuture<Boolean> removeAsync(K key, V oldValue)
key - the key whose associated value is to be returned.oldValue - the value expected to be associated with the specified key.javax.cache.Cache#remove(K,V),
ICompletableFutureICompletableFuture<V> getAndRemoveAsync(K key)
key - the key whose associated value is to be returned.javax.cache.Cache#getAndRemove(K),
ICompletableFutureICompletableFuture<Boolean> replaceAsync(K key, V value)
key - the key whose associated value is to be returned.value - the value to be associated with the specified key.javax.cache.Cache#replace(K,V),
ICompletableFutureICompletableFuture<Boolean> replaceAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.javax.cache.Cache#replace(K,V),
ICompletableFutureICompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
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.javax.cache.Cache#replace(K,V,V),
ICompletableFutureICompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.javax.cache.Cache#replace(K,V,V),
ICompletableFutureICompletableFuture<V> getAndReplaceAsync(K key, V value)
key - the key with which the specified value is associated.value - the value to be associated with the specified key.javax.cache.Cache#getAndReplace(K,V),
ICompletableFutureICompletableFuture<V> getAndReplaceAsync(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.javax.cache.Cache#getAndReplace(K,V),
ICompletableFutureV get(K key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
key - the key whose associated value is to be returned.expiryPolicy - custom expiry policy for this operation.javax.cache.Cache#get(K),
ICompletableFutureMap<K,V> getAll(Set<? extends K> keys, javax.cache.expiry.ExpiryPolicy expiryPolicy)
keys - the keys whose associated values are to be returned.expiryPolicy - custom expiry policy for this operation.Cache.getAll(java.util.Set),
ICompletableFuturevoid put(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.javax.cache.Cache#put(K,V),
ICompletableFutureV getAndPut(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.javax.cache.Cache#getAndPut(K,V),
ICompletableFuturevoid putAll(Map<? extends K,? extends V> map, javax.cache.expiry.ExpiryPolicy expiryPolicy)
map - the mappings to be stored in this cache.expiryPolicy - custom expiry policy for this operation.Cache.putAll(java.util.Map),
ICompletableFutureboolean putIfAbsent(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.javax.cache.Cache#putIfAbsent(K,V),
ICompletableFutureboolean replace(K key, V oldValue, V newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.javax.cache.Cache#replace(K,V,V),
ICompletableFutureboolean replace(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.V getAndReplace(K key, V value, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.javax.cache.Cache#getAndReplace(K,V),
ICompletableFutureint size()
void destroy()
CacheManager.destroyCache(String)CacheStatistics getLocalCacheStatistics()
Copyright © 2014 Hazelcast, Inc.. All Rights Reserved.