Interface ClientCache<K,V>
-
public interface ClientCache<K,V>
Thin client cache.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Clears the contents of the cache.void
clear(K key)
Clears entry with specified key from the cache.void
clearAll(Set<? extends K> keys)
Clears entries with specified keys from the cache.IgniteClientFuture<Void>
clearAllAsync(Set<? extends K> keys)
Clears entries with specified keys from the cache asynchronously.IgniteClientFuture<Void>
clearAsync()
Clears the contents of the cache asynchronously.IgniteClientFuture<Void>
clearAsync(K key)
Clears entry with specified key from the cache asynchronously.boolean
containsKey(K key)
Determines if theClientCache
contains an entry for the specified key.IgniteClientFuture<Boolean>
containsKeyAsync(K key)
Determines if theClientCache
contains an entry for the specified key asynchronously.boolean
containsKeys(Set<? extends K> keys)
Determines if theClientCache
contains entries for the specified keys.IgniteClientFuture<Boolean>
containsKeysAsync(Set<? extends K> keys)
Determines if theClientCache
contains entries for the specified keys asynchronously.void
deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
Deregisters a listener, using theCacheEntryListenerConfiguration
that was used to register it.V
get(K key)
Gets an entry from the cache.Map<K,V>
getAll(Set<? extends K> keys)
Gets a collection of entries from theClientCache
, returning them asMap
of the values associated with the set of keys requested.IgniteClientFuture<Map<K,V>>
getAllAsync(Set<? extends K> keys)
Gets a collection of entries from theClientCache
, returning them asMap
of the values associated with the set of keys requested.V
getAndPut(K key, V val)
Associates the specified value with the specified key in this cache, returning an existing value if one existed.IgniteClientFuture<V>
getAndPutAsync(K key, V val)
Associates the specified value with the specified key in this cache, returning an existing value if one existed.V
getAndPutIfAbsent(K key, V val)
Atomically associates the specified key with the given value if it is not already associated with a value.IgniteClientFuture<V>
getAndPutIfAbsentAsync(K key, V val)
Atomically associates the specified key with the given value if it is not already associated with a value.V
getAndRemove(K key)
Atomically removes the entry for a key only if currently mapped to some value.IgniteClientFuture<V>
getAndRemoveAsync(K key)
Atomically removes the entry for a key only if currently mapped to some value.V
getAndReplace(K key, V val)
Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.IgniteClientFuture<V>
getAndReplaceAsync(K key, V val)
Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.IgniteClientFuture<V>
getAsync(K key)
Gets an entry from the cache asynchronously.ClientCacheConfiguration
getConfiguration()
IgniteClientFuture<ClientCacheConfiguration>
getConfigurationAsync()
Gets the cache configuration asynchronously.String
getName()
<T> T
invoke(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProc, Object... arguments)
Invokes anEntryProcessor
against theCache.Entry
specified by the provided key.<T> Map<K,javax.cache.processor.EntryProcessorResult<T>>
invokeAll(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProc, Object... args)
Invokes eachEntryProcessor
against the set ofCache.Entry
s specified by the set of keys.<T> IgniteClientFuture<Map<K,javax.cache.processor.EntryProcessorResult<T>>>
invokeAllAsync(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProc, Object... args)
Asynchronously invokes eachEntryProcessor
against the set ofCache.Entry
s specified by the set of keys.<T> IgniteClientFuture<T>
invokeAsync(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProc, Object... arguments)
Asynchronously invokes anEntryProcessor
against theCache.Entry
specified by the provided key.void
put(K key, V val)
Associates the specified value with the specified key in the cache.void
putAll(Map<? extends K,? extends V> map)
Copies all of the entries from the specified map to theClientCache
.IgniteClientFuture<Void>
putAllAsync(Map<? extends K,? extends V> map)
Copies all of the entries from the specified map to theClientCache
.IgniteClientFuture<Void>
putAsync(K key, V val)
Associates the specified value with the specified key in the cache asynchronously.boolean
putIfAbsent(K key, V val)
Atomically associates the specified key with the given value if it is not already associated with a value.IgniteClientFuture<Boolean>
putIfAbsentAsync(K key, V val)
Atomically associates the specified key with the given value if it is not already associated with a value.<R> QueryCursor<R>
query(ContinuousQuery<K,V> qry, ClientDisconnectListener disconnectListener)
StartContinuousQuery
on the cache.<R> QueryCursor<R>
query(Query<R> qry)
Queries cache.FieldsQueryCursor<List<?>>
query(SqlFieldsQuery qry)
Convenience method to executeSqlFieldsQuery
.void
registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
Registers aCacheEntryListener
.void
registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration, ClientDisconnectListener disconnectListener)
Registers aCacheEntryListener
.boolean
remove(K key)
Removes the mapping for a key from this cache if it is present.boolean
remove(K key, V oldVal)
Atomically removes the mapping for a key only if currently mapped to the given value.void
removeAll()
Removes all of the mappings from this cache.void
removeAll(Set<? extends K> keys)
Removes entries for the specified keys.IgniteClientFuture<Void>
removeAllAsync()
Removes all of the mappings from this cache.IgniteClientFuture<Void>
removeAllAsync(Set<? extends K> keys)
Removes entries for the specified keys.IgniteClientFuture<Boolean>
removeAsync(K key)
Removes the mapping for a key from this cache if it is present.IgniteClientFuture<Boolean>
removeAsync(K key, V oldVal)
Atomically removes the mapping for a key only if currently mapped to the given value.boolean
replace(K key, V val)
Atomically replaces the entry for a key only if currently mapped to some value.boolean
replace(K key, V oldVal, V newVal)
Atomically replaces the entry for a key only if currently mapped to a given value.IgniteClientFuture<Boolean>
replaceAsync(K key, V val)
Atomically replaces the entry for a key only if currently mapped to some value.IgniteClientFuture<Boolean>
replaceAsync(K key, V oldVal, V newVal)
Atomically replaces the entry for a key only if currently mapped to a given value.int
size(CachePeekMode... peekModes)
Gets the number of all entries cached across all nodes.IgniteClientFuture<Integer>
sizeAsync(CachePeekMode... peekModes)
Gets the number of all entries cached across all nodes.<K1,V1>
ClientCache<K1,V1>withExpirePolicy(javax.cache.expiry.ExpiryPolicy expirePlc)
Returns cache with the specified expired policy set.<K1,V1>
ClientCache<K1,V1>withKeepBinary()
Returns cache that will operate with binary objects.
-
-
-
Method Detail
-
get
V get(K key) throws ClientException
Gets an entry from the cache.- Parameters:
key
- the key whose associated value is to be returned- Returns:
- the element, or null, if it does not exist.
- Throws:
NullPointerException
- if the key is null.ClientException
-
getAsync
IgniteClientFuture<V> getAsync(K key)
Gets an entry from the cache asynchronously.- Parameters:
key
- Key.- Returns:
- a Future representing pending completion of the operation. Future result is the cache entry value or null if it does not exist.
-
put
void put(K key, V val) throws ClientException
Associates the specified value with the specified key in the cache.If the
ClientCache
previously contained a mapping for the key, the old value is replaced by the specified value.- Parameters:
key
- key with which the specified value is to be associatedval
- value to be associated with the specified key.- Throws:
NullPointerException
- if key is null or if value is null.ClientException
-
putAsync
IgniteClientFuture<Void> putAsync(K key, V val) throws ClientException
Associates the specified value with the specified key in the cache asynchronously.If the
ClientCache
previously contained a mapping for the key, the old value is replaced by the specified value.- Parameters:
key
- key with which the specified value is to be associatedval
- value to be associated with the specified key.- Returns:
- a Future representing pending completion of the operation.
- Throws:
NullPointerException
- if key is null or if value is null.ClientException
-
containsKey
boolean containsKey(K key) throws ClientException
Determines if theClientCache
contains an entry for the specified key.More formally, returns true if and only if this cache contains a mapping for a key k such that key.equals(k). (There can be at most one such mapping)
- Parameters:
key
- key whose presence in this cache is to be tested.- Returns:
- true if this map contains a mapping for the specified key.
- Throws:
ClientException
-
containsKeyAsync
IgniteClientFuture<Boolean> containsKeyAsync(K key) throws ClientException
Determines if theClientCache
contains an entry for the specified key asynchronously.More formally, returns true if and only if this cache contains a mapping for a key k such that key.equals(k). (There can be at most one such mapping)
- Parameters:
key
- key whose presence in this cache is to be tested.- Returns:
- a Future representing pending completion of the operation. Future result is true if this map contains a mapping for the specified key.
- Throws:
ClientException
-
containsKeys
boolean containsKeys(Set<? extends K> keys) throws ClientException
Determines if theClientCache
contains entries for the specified keys.- Parameters:
keys
- Keys whose presence in this cache is to be tested.- Returns:
True
if this cache contains a mapping for the specified keys.- Throws:
ClientException
-
containsKeysAsync
IgniteClientFuture<Boolean> containsKeysAsync(Set<? extends K> keys) throws ClientException
Determines if theClientCache
contains entries for the specified keys asynchronously.- Parameters:
keys
- Keys whose presence in this cache is to be tested.- Returns:
- Future representing pending completion of the operation.
Future result is
true
if this map contains a mapping for the specified keys. - Throws:
ClientException
-
getName
String getName()
- Returns:
- The name of the cache.
-
getConfiguration
ClientCacheConfiguration getConfiguration() throws ClientException
- Returns:
- The cache configuration.
- Throws:
ClientException
-
getConfigurationAsync
IgniteClientFuture<ClientCacheConfiguration> getConfigurationAsync() throws ClientException
Gets the cache configuration asynchronously.- Returns:
- a Future representing pending completion of the operation, which wraps the cache configuration.
- Throws:
ClientException
-
size
int size(CachePeekMode... peekModes) throws ClientException
Gets the number of all entries cached across all nodes. By default, ifpeekModes
value isn't provided, only size of primary copies across all nodes will be returned. This behavior is identical to calling this method withCachePeekMode.PRIMARY
peek mode.NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
- Parameters:
peekModes
- Optional peek modes. If not provided, then total cache size is returned.- Returns:
- The number of all entries cached across all nodes.
- Throws:
ClientException
-
sizeAsync
IgniteClientFuture<Integer> sizeAsync(CachePeekMode... peekModes) throws ClientException
Gets the number of all entries cached across all nodes. By default, ifpeekModes
value isn't provided, only size of primary copies across all nodes will be returned. This behavior is identical to calling this method withCachePeekMode.PRIMARY
peek mode.NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
- Parameters:
peekModes
- Optional peek modes. If not provided, then total cache size is returned.- Returns:
- a Future representing pending completion of the operation, which wraps the cache size.
- Throws:
ClientException
-
getAll
Map<K,V> getAll(Set<? extends K> keys) throws ClientException
Gets a collection of entries from theClientCache
, returning them asMap
of the values associated with the set of keys requested.- Parameters:
keys
- The keys whose associated values are to be returned.- Returns:
- A map of entries that were found for the given keys. Keys not found in the cache are not in the returned map.
- Throws:
ClientException
-
getAllAsync
IgniteClientFuture<Map<K,V>> getAllAsync(Set<? extends K> keys) throws ClientException
Gets a collection of entries from theClientCache
, returning them asMap
of the values associated with the set of keys requested.- Parameters:
keys
- The keys whose associated values are to be returned.- Returns:
- a Future representing pending completion of the operation, which wraps a map of entries that were found for the given keys. Keys not found in the cache are not in the returned map.
- Throws:
ClientException
-
putAll
void putAll(Map<? extends K,? extends V> map) throws ClientException
Copies all of the entries from the specified map to theClientCache
.The effect of this call is equivalent to that of calling
put(k, v)
on this cache once for each mapping from key k to value v in the specified map.The order in which the individual puts occur is undefined.
The behavior of this operation is undefined if entries in the cache corresponding to entries in the map are modified or removed while this operation is in progress, or if map is modified while the operation is in progress.
- Parameters:
map
- Mappings to be stored in this cache.- Throws:
ClientException
-
putAllAsync
IgniteClientFuture<Void> putAllAsync(Map<? extends K,? extends V> map) throws ClientException
Copies all of the entries from the specified map to theClientCache
.The effect of this call is equivalent to that of calling
put(k, v)
on this cache once for each mapping from key k to value v in the specified map.The order in which the individual puts occur is undefined.
The behavior of this operation is undefined if entries in the cache corresponding to entries in the map are modified or removed while this operation is in progress, or if map is modified while the operation is in progress.
- Parameters:
map
- Mappings to be stored in this cache.- Returns:
- a Future representing pending completion of the operation.
- Throws:
ClientException
-
replace
boolean replace(K key, V oldVal, V newVal) throws ClientException
Atomically replaces the entry for a key only if currently mapped to a given value.This is equivalent to performing the following operations as a single atomic action:
if (cache.containsKey(key) && equals(cache.get(key), oldValue)) { cache.put(key, newValue); return true; } else { return false; }
- Parameters:
key
- Key with which the specified value is associated.oldVal
- Value expected to be associated with the specified key.newVal
- Value to be associated with the specified key.- Returns:
- true if the value was replaced
- Throws:
ClientException
-
replaceAsync
IgniteClientFuture<Boolean> replaceAsync(K key, V oldVal, V newVal) throws ClientException
Atomically replaces the entry for a key only if currently mapped to a given value.This is equivalent to performing the following operations as a single atomic action:
if (cache.containsKey(key) && equals(cache.get(key), oldValue)) { cache.put(key, newValue); return true; } else { return false; }
- Parameters:
key
- Key with which the specified value is associated.oldVal
- Value expected to be associated with the specified key.newVal
- Value to be associated with the specified key.- Returns:
- a Future representing pending completion of the operation, which wraps a value indicating whether the cache value was replaced.
- Throws:
ClientException
-
replace
boolean replace(K key, V val) throws ClientException
Atomically replaces the entry for a key only if currently mapped to some value.This is equivalent to performing the following operations as a single atomic action:
if (cache.containsKey(key)) { cache.put(key, value); return true; } else { return false; }
- Parameters:
key
- The key with which the specified value is associated.val
- The value to be associated with the specified key.- Returns:
- true if the value was replaced.
- Throws:
ClientException
-
replaceAsync
IgniteClientFuture<Boolean> replaceAsync(K key, V val) throws ClientException
Atomically replaces the entry for a key only if currently mapped to some value.This is equivalent to performing the following operations as a single atomic action:
if (cache.containsKey(key)) { cache.put(key, value); return true; } else { return false; }
- Parameters:
key
- The key with which the specified value is associated.val
- The value to be associated with the specified key.- Returns:
- a Future representing pending completion of the operation, which wraps a value indicating whether the cache value was replaced.
- Throws:
ClientException
-
remove
boolean remove(K key) throws ClientException
Removes the mapping for a key from this cache if it is present.More formally, if this cache contains a mapping from key k to value v such that
(key==null ? k==null : key.equals(k))
, that mapping is removed. (The cache can contain at most one such mapping.)Returns true if this cache previously associated the key, or false if the cache contained no mapping for the key.
The cache will not contain a mapping for the specified key once the call returns.
- Parameters:
key
- Key whose mapping is to be removed from the cache.- Returns:
- false if there was no matching key.
- Throws:
ClientException
-
removeAsync
IgniteClientFuture<Boolean> removeAsync(K key) throws ClientException
Removes the mapping for a key from this cache if it is present.More formally, if this cache contains a mapping from key k to value v such that
(key==null ? k==null : key.equals(k))
, that mapping is removed. (The cache can contain at most one such mapping.)Returns true if this cache previously associated the key, or false if the cache contained no mapping for the key.
The cache will not contain a mapping for the specified key once the call returns.
- Parameters:
key
- Key whose mapping is to be removed from the cache.- Returns:
- a Future representing pending completion of the operation, which wraps a value indicating whether the cache value was removed.
- Throws:
ClientException
-
remove
boolean remove(K key, V oldVal) throws ClientException
Atomically removes the mapping for a key only if currently mapped to the given value.This is equivalent to performing the following operations as a single atomic action:
if (cache.containsKey(key) && equals(cache.get(key), oldValue) { cache.remove(key); return true; } else { return false; }
- Parameters:
key
- Key whose mapping is to be removed from the cache.oldVal
- Value expected to be associated with the specified key.- Returns:
- false if there was no matching key.
- Throws:
ClientException
-
removeAsync
IgniteClientFuture<Boolean> removeAsync(K key, V oldVal) throws ClientException
Atomically removes the mapping for a key only if currently mapped to the given value.This is equivalent to performing the following operations as a single atomic action:
if (cache.containsKey(key) && equals(cache.get(key), oldValue) { cache.remove(key); return true; } else { return false; }
- Parameters:
key
- Key whose mapping is to be removed from the cache.oldVal
- Value expected to be associated with the specified key.- Returns:
- a Future representing pending completion of the operation, which wraps a value indicating whether the cache value was removed.
- Throws:
ClientException
-
removeAll
void removeAll(Set<? extends K> keys) throws ClientException
Removes entries for the specified keys.The order in which the individual entries are removed is undefined.
- Parameters:
keys
- The keys to remove.- Throws:
ClientException
-
removeAllAsync
IgniteClientFuture<Void> removeAllAsync(Set<? extends K> keys) throws ClientException
Removes entries for the specified keys.The order in which the individual entries are removed is undefined.
- Parameters:
keys
- The keys to remove.- Returns:
- a Future representing pending completion of the operation.
- Throws:
ClientException
-
removeAll
void removeAll() throws ClientException
Removes all of the mappings from this cache.The order that the individual entries are removed is undefined.
This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.
This is potentially an expensive operation as listeners are invoked. Use
clear()
to avoid this.- Throws:
ClientException
-
removeAllAsync
IgniteClientFuture<Void> removeAllAsync() throws ClientException
Removes all of the mappings from this cache.The order that the individual entries are removed is undefined.
This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.
This is potentially an expensive operation as listeners are invoked. Use
clear()
to avoid this.- Returns:
- a Future representing pending completion of the operation.
- Throws:
ClientException
-
getAndPut
V getAndPut(K key, V val) throws ClientException
Associates the specified value with the specified key in this cache, returning an existing value if one existed.If the cache previously contained a mapping for the key, the old value is replaced by the specified value. (A cache c is said to contain a mapping for a key k if and only if
c.containsKey(k)
would return true.)The previous value is returned, or null if there was no value associated with the key previously.
- Parameters:
key
- Key with which the specified value is to be associated.val
- Value to be associated with the specified key.- Returns:
- The value associated with the key at the start of the operation or null if none was associated.
- Throws:
ClientException
-
getAndPutAsync
IgniteClientFuture<V> getAndPutAsync(K key, V val) throws ClientException
Associates the specified value with the specified key in this cache, returning an existing value if one existed.If the cache previously contained a mapping for the key, the old value is replaced by the specified value. (A cache c is said to contain a mapping for a key k if and only if
c.containsKey(k)
would return true.)The previous value is returned, or null if there was no value associated with the key previously.
- Parameters:
key
- Key with which the specified value is to be associated.val
- Value to be associated with the specified key.- Returns:
- a Future representing pending completion of the operation, which wraps the value associated with the key at the start of the operation or null if none was associated.
- Throws:
ClientException
-
getAndRemove
V getAndRemove(K key) throws ClientException
Atomically removes the entry for a key only if currently mapped to some value.This is equivalent to performing the following operations as a single atomic action:
if (cache.containsKey(key)) { V oldValue = cache.get(key); cache.remove(key); return oldValue; } else { return null; }
- Parameters:
key
- Key with which the specified value is associated.- Returns:
- The value if one existed or null if no mapping existed for this key.
- Throws:
ClientException
-
getAndRemoveAsync
IgniteClientFuture<V> getAndRemoveAsync(K key) throws ClientException
Atomically removes the entry for a key only if currently mapped to some value.This is equivalent to performing the following operations as a single atomic action:
if (cache.containsKey(key)) { V oldValue = cache.get(key); cache.remove(key); return oldValue; } else { return null; }
- Parameters:
key
- Key with which the specified value is associated.- Returns:
- a Future representing pending completion of the operation, which wraps the value if one existed or null if no mapping existed for this key.
- Throws:
ClientException
-
getAndReplace
V getAndReplace(K key, V val) throws ClientException
Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.This is equivalent to performing the following operations as a single atomic action:
if (cache.containsKey(key)) { V oldValue = cache.get(key); cache.put(key, value); return oldValue; } else { return null; }
- Parameters:
key
- Key with which the specified value is associated.val
- Value to be associated with the specified key.- Returns:
- The previous value associated with the specified key, or null if there was no mapping for the key.
- Throws:
ClientException
-
getAndReplaceAsync
IgniteClientFuture<V> getAndReplaceAsync(K key, V val) throws ClientException
Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.This is equivalent to performing the following operations as a single atomic action:
if (cache.containsKey(key)) { V oldValue = cache.get(key); cache.put(key, value); return oldValue; } else { return null; }
- Parameters:
key
- Key with which the specified value is associated.val
- Value to be associated with the specified key.- Returns:
- a Future representing pending completion of the operation, which wraps the previous value associated with the specified key, or null if there was no mapping for the key.
- Throws:
ClientException
-
putIfAbsent
boolean putIfAbsent(K key, V val) throws ClientException
Atomically associates the specified key with the given value if it is not already associated with a value.This is equivalent to performing the following operations as a single atomic action:
if (!cache.containsKey(key)) { cache.put(key, value); return true; } else { return false; }
- Parameters:
key
- Key with which the specified value is to be associated.val
- Value to be associated with the specified key.- Returns:
- true if a value was set.
- Throws:
ClientException
-
putIfAbsentAsync
IgniteClientFuture<Boolean> putIfAbsentAsync(K key, V val) throws ClientException
Atomically associates the specified key with the given value if it is not already associated with a value.This is equivalent to performing the following operations as a single atomic action:
if (!cache.containsKey(key)) { cache.put(key, value); return true; } else { return false; }
- Parameters:
key
- Key with which the specified value is to be associated.val
- Value to be associated with the specified key.- Returns:
- a Future representing pending completion of the operation, which wraps the value indicating whether a value was set.
- Throws:
ClientException
-
getAndPutIfAbsent
V getAndPutIfAbsent(K key, V val) throws ClientException
Atomically associates the specified key with the given value if it is not already associated with a value.This is equivalent to performing the following operations as a single atomic action:
if (!cache.containsKey(key)) { cache.put(key, value); return null; } else { return cache.get(key); }
- Parameters:
key
- Key with which the specified value is to be associated.val
- Value to be associated with the specified key.- Returns:
- Value that is already associated with the specified key, or
null
if no value was associated with the specified key and a value was set. - Throws:
ClientException
-
getAndPutIfAbsentAsync
IgniteClientFuture<V> getAndPutIfAbsentAsync(K key, V val) throws ClientException
Atomically associates the specified key with the given value if it is not already associated with a value.This is equivalent to performing the following operations as a single atomic action:
if (!cache.containsKey(key)) { cache.put(key, value); return null; } else { return cache.get(key); }
- Parameters:
key
- Key with which the specified value is to be associated.val
- Value to be associated with the specified key.- Returns:
- Future representing pending completion of the operation, which wraps the value that is already
associated with the specified key, or
null
if no value was associated with the specified key and a value was set. - Throws:
ClientException
-
clear
void clear() throws ClientException
Clears the contents of the cache. In contrast toremoveAll()
, this method does not notify event listeners and cache writers.- Throws:
ClientException
-
clearAsync
IgniteClientFuture<Void> clearAsync() throws ClientException
Clears the contents of the cache asynchronously. In contrast toremoveAll()
, this method does not notify event listeners and cache writers.- Returns:
- a Future representing pending completion of the operation.
- Throws:
ClientException
-
clear
void clear(K key) throws ClientException
Clears entry with specified key from the cache. In contrast toremove(Object)
, this method does not notify event listeners and cache writers.- Parameters:
key
- Cache entry key to clear.- Throws:
ClientException
-
clearAsync
IgniteClientFuture<Void> clearAsync(K key) throws ClientException
Clears entry with specified key from the cache asynchronously. In contrast toremoveAsync(Object)
, this method does not notify event listeners and cache writers.- Parameters:
key
- Cache entry key to clear.- Returns:
- Future representing pending completion of the operation.
- Throws:
ClientException
-
clearAll
void clearAll(Set<? extends K> keys) throws ClientException
Clears entries with specified keys from the cache. In contrast toremoveAll(Set)
, this method does not notify event listeners and cache writers.- Parameters:
keys
- Cache entry keys to clear.- Throws:
ClientException
-
clearAllAsync
IgniteClientFuture<Void> clearAllAsync(Set<? extends K> keys) throws ClientException
Clears entries with specified keys from the cache asynchronously. In contrast toremoveAllAsync(Set)
, this method does not notify event listeners and cache writers.- Parameters:
keys
- Cache entry keys to clear.- Returns:
- Future representing pending completion of the operation.
- Throws:
ClientException
-
invoke
<T> T invoke(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProc, Object... arguments) throws javax.cache.processor.EntryProcessorException, ClientException
Invokes anEntryProcessor
against theCache.Entry
specified by the provided key. If anCache.Entry
does not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogateCache.Entry
, consisting of the key with a null value is used instead.An instance of entry processor must be stateless as it may be invoked multiple times on primary and backup nodes in the cache. It is guaranteed that the value passed to the entry processor will be always the same.
- Type Parameters:
T
- Type of the cache entry processing result.- Parameters:
key
- The key to the entry.entryProc
- TheEntryProcessor
to invoke.arguments
- Additional arguments to pass to theEntryProcessor
.- Returns:
- The result of the processing, if any, defined by the
EntryProcessor
implementation. - Throws:
NullPointerException
- If key orEntryProcessor
is null.javax.cache.processor.EntryProcessorException
- If an exception is thrown by theEntryProcessor
, a Caching Implementation must wrap anyException
thrown wrapped in anEntryProcessorException
.ClientException
- If operation is failed.
-
invokeAsync
<T> IgniteClientFuture<T> invokeAsync(K key, javax.cache.processor.EntryProcessor<K,V,T> entryProc, Object... arguments) throws ClientException
Asynchronously invokes anEntryProcessor
against theCache.Entry
specified by the provided key. If anCache.Entry
does not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogateCache.Entry
, consisting of the key with a null value is used instead.An instance of entry processor must be stateless as it may be invoked multiple times on primary and backup nodes in the cache. It is guaranteed that the value passed to the entry processor will be always the same.
- Type Parameters:
T
- Type of the cache entry processing result.- Parameters:
key
- The key to the entry.entryProc
- TheEntryProcessor
to invoke.arguments
- Additional arguments to pass to theEntryProcessor
.- Returns:
- Future representing pending completion of the operation.
- Throws:
NullPointerException
- If key orEntryProcessor
is null.ClientException
- If operation is failed.
-
invokeAll
<T> Map<K,javax.cache.processor.EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProc, Object... args) throws ClientException
Invokes eachEntryProcessor
against the set ofCache.Entry
s specified by the set of keys.If an
Cache.Entry
does not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogateCache.Entry
, consisting of the key and a value of null is provided.The order that the entries for the keys are processed is undefined. Implementations may choose to process the entries in any order, including concurrently. Furthermore there is no guarantee implementations will use the same
EntryProcessor
instance to process each entry, as the case may be in a non-local cache topology.The result of executing the
EntryProcessor
is returned as aMap
ofEntryProcessorResult
s, one result per key. Should theEntryProcessor
or Caching implementation throw an exception, the exception is wrapped and re-thrown when a call toEntryProcessorResult.get()
is made.Keys are locked in the order in which they appear in key set. It is caller's responsibility to make sure keys always follow same order, such as by using
TreeSet
. Using unordered map, such asHashSet
, while calling this method in parallel will lead to deadlock.- Type Parameters:
T
- Type of the cache entry processing result.- Parameters:
keys
- The set of keys for entries to proces.entryProc
- The EntryProcessor to invoke.args
- Additional arguments to pass to theEntryProcessor
.- Returns:
- The map of
EntryProcessorResult
s of the processing per key, if any, defined by theEntryProcessor
implementation. No mappings will be returned forEntryProcessor
s that return anull
value for a key. - Throws:
NullPointerException
- If keys orEntryProcessor
is null.ClientException
- If operation is failed.
-
invokeAllAsync
<T> IgniteClientFuture<Map<K,javax.cache.processor.EntryProcessorResult<T>>> invokeAllAsync(Set<? extends K> keys, javax.cache.processor.EntryProcessor<K,V,T> entryProc, Object... args) throws ClientException
Asynchronously invokes eachEntryProcessor
against the set ofCache.Entry
s specified by the set of keys.If an
Cache.Entry
does not exist for the specified key, an attempt is made to load it (if a loader is configured) or a surrogateCache.Entry
, consisting of the key and a value of null is provided.The order that the entries for the keys are processed is undefined. Implementations may choose to process the entries in any order, including concurrently. Furthermore there is no guarantee implementations will use the same
EntryProcessor
instance to process each entry, as the case may be in a non-local cache topology.The result of executing the
EntryProcessor
is returned in the future as aMap
ofEntryProcessorResult
s, one result per key. Should theEntryProcessor
or Caching implementation throw an exception, the exception is wrapped and re-thrown when a call toEntryProcessorResult.get()
is made.Keys are locked in the order in which they appear in key set. It is caller's responsibility to make sure keys always follow same order, such as by using
TreeSet
. Using unordered map, such asHashSet
, while calling this method in parallel will lead to deadlock.- Type Parameters:
T
- Type of the cache entry processing result.- Parameters:
keys
- The set of keys for entries to proces.entryProc
- The EntryProcessor to invoke.args
- Additional arguments to pass to theEntryProcessor
.- Returns:
- Future representing pending completion of the operation.
- Throws:
NullPointerException
- If keys orEntryProcessor
is null.ClientException
- If operation is failed.
-
withKeepBinary
<K1,V1> ClientCache<K1,V1> withKeepBinary()
Returns cache that will operate with binary objects.Cache returned by this method will not be forced to deserialize binary objects, so keys and values will be returned from cache API methods without changes. Therefore, signature of the cache can contain only following types:
org.apache.ignite.binary.BinaryObject
for binary classes- All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)
- Arrays of primitives (byte[], int[], ...)
String
and array ofString
sUUID
and array ofUUID
sDate
and array ofDate
sTimestamp
and array ofTimestamp
s- Enums and array of enums
- Maps, collections and array of objects (but objects inside them will still be converted if they are binary)
For example, if you use
Integer
as a key andValue
class as a value (which will be stored in binary format), you should acquire following projection to avoid deserialization:CacheClient<Integer, BinaryObject> prj = cache.withKeepBinary(); // Value is not deserialized and returned in binary format. BinaryObject po = prj.get(1);
Note that this method makes sense only if cache is working in binary mode if default marshaller is used. If not, this method is no-op and will return current cache.
- Type Parameters:
K1
- Client cache key type.V1
- Client cache value type.- Returns:
- New cache instance for binary objects.
-
withExpirePolicy
<K1,V1> ClientCache<K1,V1> withExpirePolicy(javax.cache.expiry.ExpiryPolicy expirePlc)
Returns cache with the specified expired policy set. This policy will be used for each operation invoked on the returned cache.- Type Parameters:
K1
- Client cache key type.V1
- Client cache value type.- Parameters:
expirePlc
- Expiration policy.- Returns:
- Cache instance with the specified expiry policy set.
-
query
<R> QueryCursor<R> query(Query<R> qry)
Queries cache. SupportsScanQuery
,SqlFieldsQuery
andContinuousQuery
.NOTE: For continuous query listeners there is no failover in case of client channel failure, this event should be handled on the user's side. Use
query(ContinuousQuery, ClientDisconnectListener)
method to get notified about client disconnected event viaClientDisconnectListener
interface if you need it.- Type Parameters:
R
- Query result type.- Parameters:
qry
- Query.- Returns:
- Cursor.
-
query
<R> QueryCursor<R> query(ContinuousQuery<K,V> qry, ClientDisconnectListener disconnectListener)
StartContinuousQuery
on the cache.NOTE: There is no failover in case of client channel failure, this event should be handled on the user's side. Use
disconnectListener
to handle this.- Type Parameters:
R
- Query result type.- Parameters:
qry
- Query.disconnectListener
- Listener of client disconnected event.- Returns:
- Cursor.
-
query
FieldsQueryCursor<List<?>> query(SqlFieldsQuery qry)
Convenience method to executeSqlFieldsQuery
.- Parameters:
qry
- Query.- Returns:
- Cursor.
-
registerCacheEntryListener
void registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
Registers aCacheEntryListener
. The suppliedCacheEntryListenerConfiguration
is used to instantiate a listener and apply it to those events specified in the configuration.NOTE: There is no failover in case of client channel failure, this event should be handled on the user's side. Use
registerCacheEntryListener(CacheEntryListenerConfiguration, ClientDisconnectListener)
method to get notified about client disconnected event viaClientDisconnectListener
interface if you need it.- Parameters:
cacheEntryListenerConfiguration
- a factory and related configuration for creating the listener.- Throws:
IllegalArgumentException
- is the same CacheEntryListenerConfiguration is used more than once or if some unsupported by thin client properties are set.- See Also:
CacheEntryListener
-
registerCacheEntryListener
void registerCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration, ClientDisconnectListener disconnectListener)
Registers aCacheEntryListener
. The suppliedCacheEntryListenerConfiguration
is used to instantiate a listener and apply it to those events specified in the configuration.NOTE: There is no failover in case of client channel failure, this event should be handled on the user's side. Use
disconnectListener
to handle this.- Parameters:
cacheEntryListenerConfiguration
- a factory and related configuration for creating the listener.disconnectListener
- Listener of client disconnected event.- Throws:
IllegalArgumentException
- is the same CacheEntryListenerConfiguration is used more than once or if some unsupported by thin client properties are set.- See Also:
CacheEntryListener
-
deregisterCacheEntryListener
void deregisterCacheEntryListener(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
Deregisters a listener, using theCacheEntryListenerConfiguration
that was used to register it.- Parameters:
cacheEntryListenerConfiguration
- the factory and related configuration that was used to create the listener.
-
-