Class TcpClientCache<K,​V>

    • Field Detail

      • NON_TRANSACTIONAL_CLIENT_CACHE_CLEAR_IN_TX_ERROR_MESSAGE

        public static final String NON_TRANSACTIONAL_CLIENT_CACHE_CLEAR_IN_TX_ERROR_MESSAGE
        Exception thrown when a non-transactional ClientCache clear operation is invoked within a transaction.
        See Also:
        Constant Field Values
    • Method Detail

      • get

        public V get​(K key)
              throws ClientException
        Gets an entry from the cache.
        Specified by:
        get in interface ClientCache<K,​V>
        Parameters:
        key - the key whose associated value is to be returned
        Returns:
        the element, or null, if it does not exist.
        Throws:
        ClientException
      • getAsync

        public IgniteClientFuture<V> getAsync​(K key)
        Gets an entry from the cache asynchronously.
        Specified by:
        getAsync in interface ClientCache<K,​V>
        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

        public 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.

        Specified by:
        put in interface ClientCache<K,​V>
        Parameters:
        key - key with which the specified value is to be associated
        val - value to be associated with the specified key.
        Throws:
        ClientException
      • putAsync

        public 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.

        Specified by:
        putAsync in interface ClientCache<K,​V>
        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.
        Throws:
        ClientException
      • containsKey

        public boolean containsKey​(K key)
                            throws ClientException
        Determines if the ClientCache 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)

        Specified by:
        containsKey in interface ClientCache<K,​V>
        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

        public IgniteClientFuture<Boolean> containsKeyAsync​(K key)
                                                     throws ClientException
        Determines if the ClientCache 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)

        Specified by:
        containsKeyAsync in interface ClientCache<K,​V>
        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

        public boolean containsKeys​(Set<? extends K> keys)
                             throws ClientException
        Determines if the ClientCache contains entries for the specified keys.
        Specified by:
        containsKeys in interface ClientCache<K,​V>
        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

        public IgniteClientFuture<Boolean> containsKeysAsync​(Set<? extends K> keys)
                                                      throws ClientException
        Determines if the ClientCache contains entries for the specified keys asynchronously.
        Specified by:
        containsKeysAsync in interface ClientCache<K,​V>
        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
      • size

        public int size​(CachePeekMode... peekModes)
                 throws ClientException
        Gets the number of all entries cached across all nodes. By default, if peekModes value isn't provided, only size of primary copies across all nodes will be returned. This behavior is identical to calling this method with CachePeekMode.PRIMARY peek mode.

        NOTE: this operation is distributed and will query all participating nodes for their cache sizes.

        Specified by:
        size in interface ClientCache<K,​V>
        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

        public IgniteClientFuture<Integer> sizeAsync​(CachePeekMode... peekModes)
                                              throws ClientException
        Gets the number of all entries cached across all nodes. By default, if peekModes value isn't provided, only size of primary copies across all nodes will be returned. This behavior is identical to calling this method with CachePeekMode.PRIMARY peek mode.

        NOTE: this operation is distributed and will query all participating nodes for their cache sizes.

        Specified by:
        sizeAsync in interface ClientCache<K,​V>
        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

        public Map<K,​V> getAll​(Set<? extends K> keys)
                              throws ClientException
        Gets a collection of entries from the ClientCache, returning them as Map of the values associated with the set of keys requested.
        Specified by:
        getAll in interface ClientCache<K,​V>
        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

        public IgniteClientFuture<Map<K,​V>> getAllAsync​(Set<? extends K> keys)
                                                       throws ClientException
        Gets a collection of entries from the ClientCache, returning them as Map of the values associated with the set of keys requested.
        Specified by:
        getAllAsync in interface ClientCache<K,​V>
        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

        public void putAll​(Map<? extends K,​? extends V> map)
                    throws ClientException
        Copies all of the entries from the specified map to the ClientCache.

        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.

        Specified by:
        putAll in interface ClientCache<K,​V>
        Parameters:
        map - Mappings to be stored in this cache.
        Throws:
        ClientException
      • putAllAsync

        public IgniteClientFuture<Void> putAllAsync​(Map<? extends K,​? extends V> map)
                                             throws ClientException
        Copies all of the entries from the specified map to the ClientCache.

        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.

        Specified by:
        putAllAsync in interface ClientCache<K,​V>
        Parameters:
        map - Mappings to be stored in this cache.
        Returns:
        a Future representing pending completion of the operation.
        Throws:
        ClientException
      • replace

        public 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;
         }
         
        Specified by:
        replace in interface ClientCache<K,​V>
        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

        public 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;
         }
         
        Specified by:
        replaceAsync in interface ClientCache<K,​V>
        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

        public 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;
         }
        Specified by:
        replace in interface ClientCache<K,​V>
        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

        public 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;
         }
        Specified by:
        replaceAsync in interface ClientCache<K,​V>
        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

        public 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.

        Specified by:
        remove in interface ClientCache<K,​V>
        Parameters:
        key - Key whose mapping is to be removed from the cache.
        Returns:
        false if there was no matching key.
        Throws:
        ClientException
      • removeAsync

        public 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.

        Specified by:
        removeAsync in interface ClientCache<K,​V>
        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

        public 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;
         }
         
        Specified by:
        remove in interface ClientCache<K,​V>
        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

        public 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;
         }
         
        Specified by:
        removeAsync in interface ClientCache<K,​V>
        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

        public 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.

        Specified by:
        removeAll in interface ClientCache<K,​V>
        Parameters:
        keys - The keys to remove.
        Throws:
        ClientException
      • removeAllAsync

        public 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.

        Specified by:
        removeAllAsync in interface ClientCache<K,​V>
        Parameters:
        keys - The keys to remove.
        Returns:
        a Future representing pending completion of the operation.
        Throws:
        ClientException
      • removeAll

        public 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 ClientCache.clear() to avoid this.

        Specified by:
        removeAll in interface ClientCache<K,​V>
        Throws:
        ClientException
      • removeAllAsync

        public 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 ClientCache.clear() to avoid this.

        Specified by:
        removeAllAsync in interface ClientCache<K,​V>
        Returns:
        a Future representing pending completion of the operation.
        Throws:
        ClientException
      • getAndPut

        public 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.

        Specified by:
        getAndPut in interface ClientCache<K,​V>
        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

        public 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.

        Specified by:
        getAndPutAsync in interface ClientCache<K,​V>
        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

        public 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;
         }
         
        Specified by:
        getAndRemove in interface ClientCache<K,​V>
        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

        public 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;
         }
         
        Specified by:
        getAndRemoveAsync in interface ClientCache<K,​V>
        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

        public 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;
         }
         
        Specified by:
        getAndReplace in interface ClientCache<K,​V>
        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

        public 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;
         }
         
        Specified by:
        getAndReplaceAsync in interface ClientCache<K,​V>
        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

        public 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;
         }
         
        Specified by:
        putIfAbsent in interface ClientCache<K,​V>
        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

        public 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;
         }
         
        Specified by:
        putIfAbsentAsync in interface ClientCache<K,​V>
        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

        public 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);
         }
         
        Specified by:
        getAndPutIfAbsent in interface ClientCache<K,​V>
        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

        public 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);
         }
         
        Specified by:
        getAndPutIfAbsentAsync in interface ClientCache<K,​V>
        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

        public void clear()
                   throws ClientException
        Clears the contents of the cache. In contrast to removeAll(), this method does not notify event listeners and CacheWriters. Specified by ClientCache.clear(). This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.
        Specified by:
        clear in interface ClientCache<K,​V>
        Throws:
        ClientException - if operation is failed.
        javax.cache.CacheException - if there is a problem during the clear.
      • clearAsync

        public IgniteClientFuture<Void> clearAsync()
                                            throws ClientException
        Clears the contents of the cache asynchronously. In contrast to removeAll(), this method does not notify event listeners and CacheWriters. Specified by ClientCache.clearAsync(). This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.
        Specified by:
        clearAsync in interface ClientCache<K,​V>
        Returns:
        a Future representing pending completion of the operation.
        Throws:
        ClientException - if operation is failed.
        javax.cache.CacheException - if there is a problem during the clear.
      • clear

        public void clear​(K key)
                   throws ClientException
        Clears entry with specified key from the cache. In contrast to remove(Object), this method does not notify event listeners and CacheWriters. Specified by ClientCache.clear(Object). This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.
        Specified by:
        clear in interface ClientCache<K,​V>
        Parameters:
        key - Cache entry key to clear.
        Throws:
        ClientException - if operation is failed.
        javax.cache.CacheException - if there is a problem during the clear.
      • clearAsync

        public IgniteClientFuture<Void> clearAsync​(K key)
                                            throws ClientException
        Clears entry with specified key from the cache asynchronously. In contrast to removeAsync(Object), this method does not notify event listeners and CacheWriters. Specified by ClientCache.clearAsync(Object). This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.
        Specified by:
        clearAsync in interface ClientCache<K,​V>
        Parameters:
        key - Cache entry key to clear.
        Returns:
        a Future representing pending completion of the operation.
        Throws:
        ClientException - if operation is failed.
        javax.cache.CacheException - if there is a problem during the clear.
      • clearAll

        public void clearAll​(Set<? extends K> keys)
                      throws ClientException
        Clears entries with specified keys from the cache. In contrast to removeAll(Set), this method does not notify event listeners and CacheWriters. Specified by ClientCache.clearAll(Set). This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.
        Specified by:
        clearAll in interface ClientCache<K,​V>
        Parameters:
        keys - Cache entry keys to clear.
        Throws:
        ClientException - if operation is failed.
        javax.cache.CacheException - if there is a problem during the clear.
      • clearAllAsync

        public IgniteClientFuture<Void> clearAllAsync​(Set<? extends K> keys)
                                               throws ClientException
        Clears entries with specified keys from the cache asynchronously. In contrast to removeAllAsync(Set), this method does not notify event listeners and CacheWriters. Specified by ClientCache.clearAllAsync(Set). This operation is not transactional. It calls broadcast closure that deletes all primary keys from remote nodes.\
        Specified by:
        clearAllAsync in interface ClientCache<K,​V>
        Parameters:
        keys - Cache entry keys to clear.
        Returns:
        Future representing pending completion of the operation.
        Throws:
        ClientException - if operation is failed.
        javax.cache.CacheException - if there is a problem during the clear.
      • invoke

        public <T> T invoke​(K key,
                            javax.cache.processor.EntryProcessor<K,​V,​T> entryProc,
                            Object... arguments)
                     throws javax.cache.processor.EntryProcessorException,
                            ClientException
        Invokes an EntryProcessor against the Cache.Entry specified by the provided key. 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 surrogate Cache.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.

        Specified by:
        invoke in interface ClientCache<K,​V>
        Type Parameters:
        T - Type of the cache entry processing result.
        Parameters:
        key - The key to the entry.
        entryProc - The EntryProcessor to invoke.
        arguments - Additional arguments to pass to the EntryProcessor.
        Returns:
        The result of the processing, if any, defined by the EntryProcessor implementation.
        Throws:
        javax.cache.processor.EntryProcessorException - If an exception is thrown by the EntryProcessor, a Caching Implementation must wrap any Exception thrown wrapped in an EntryProcessorException.
        ClientException - If operation is failed.
      • invokeAsync

        public <T> IgniteClientFuture<T> invokeAsync​(K key,
                                                     javax.cache.processor.EntryProcessor<K,​V,​T> entryProc,
                                                     Object... arguments)
                                              throws ClientException
        Asynchronously invokes an EntryProcessor against the Cache.Entry specified by the provided key. 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 surrogate Cache.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.

        Specified by:
        invokeAsync in interface ClientCache<K,​V>
        Type Parameters:
        T - Type of the cache entry processing result.
        Parameters:
        key - The key to the entry.
        entryProc - The EntryProcessor to invoke.
        arguments - Additional arguments to pass to the EntryProcessor.
        Returns:
        Future representing pending completion of the operation.
        Throws:
        ClientException - If operation is failed.
      • invokeAll

        public <T> Map<K,​javax.cache.processor.EntryProcessorResult<T>> invokeAll​(Set<? extends K> keys,
                                                                                        javax.cache.processor.EntryProcessor<K,​V,​T> entryProc,
                                                                                        Object... arguments)
                                                                                 throws ClientException
        Invokes each EntryProcessor against the set of Cache.Entrys 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 surrogate Cache.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 a Map of EntryProcessorResults, one result per key. Should the EntryProcessor or Caching implementation throw an exception, the exception is wrapped and re-thrown when a call to EntryProcessorResult.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 as HashSet, while calling this method in parallel will lead to deadlock.

        Specified by:
        invokeAll in interface ClientCache<K,​V>
        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.
        arguments - Additional arguments to pass to the EntryProcessor.
        Returns:
        The map of EntryProcessorResults of the processing per key, if any, defined by the EntryProcessor implementation. No mappings will be returned for EntryProcessors that return a null value for a key.
        Throws:
        ClientException - If operation is failed.
      • invokeAllAsync

        public <T> IgniteClientFuture<Map<K,​javax.cache.processor.EntryProcessorResult<T>>> invokeAllAsync​(Set<? extends K> keys,
                                                                                                                 javax.cache.processor.EntryProcessor<K,​V,​T> entryProc,
                                                                                                                 Object... arguments)
                                                                                                          throws ClientException
        Asynchronously invokes each EntryProcessor against the set of Cache.Entrys 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 surrogate Cache.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 a Map of EntryProcessorResults, one result per key. Should the EntryProcessor or Caching implementation throw an exception, the exception is wrapped and re-thrown when a call to EntryProcessorResult.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 as HashSet, while calling this method in parallel will lead to deadlock.

        Specified by:
        invokeAllAsync in interface ClientCache<K,​V>
        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.
        arguments - Additional arguments to pass to the EntryProcessor.
        Returns:
        Future representing pending completion of the operation.
        Throws:
        ClientException - If operation is failed.
      • withKeepBinary

        public <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 of Strings
        • UUID and array of UUIDs
        • Date and array of Dates
        • Timestamp and array of Timestamps
        • 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 and Value 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.

        Specified by:
        withKeepBinary in interface ClientCache<K,​V>
        Type Parameters:
        K1 - Client cache key type.
        V1 - Client cache value type.
        Returns:
        New cache instance for binary objects.
      • withExpirePolicy

        public <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.
        Specified by:
        withExpirePolicy in interface ClientCache<K,​V>
        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

        public <R> QueryCursor<R> query​(ContinuousQuery<K,​V> qry,
                                        ClientDisconnectListener disconnectLsnr)
        Start ContinuousQuery 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.

        Specified by:
        query in interface ClientCache<K,​V>
        Type Parameters:
        R - Query result type.
        Parameters:
        qry - Query.
        disconnectLsnr - Listener of client disconnected event.
        Returns:
        Cursor.
      • registerCacheEntryListener

        public void registerCacheEntryListener​(javax.cache.configuration.CacheEntryListenerConfiguration<K,​V> cfg)
        Registers a CacheEntryListener. The supplied CacheEntryListenerConfiguration 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 ClientCache.registerCacheEntryListener(CacheEntryListenerConfiguration, ClientDisconnectListener) method to get notified about client disconnected event via ClientDisconnectListener interface if you need it.

        Specified by:
        registerCacheEntryListener in interface ClientCache<K,​V>
        Parameters:
        cfg - a factory and related configuration for creating the listener.
        See Also:
        CacheEntryListener
      • registerCacheEntryListener

        public void registerCacheEntryListener​(javax.cache.configuration.CacheEntryListenerConfiguration<K,​V> cfg,
                                               ClientDisconnectListener disconnectLsnr)
        Registers a CacheEntryListener. The supplied CacheEntryListenerConfiguration 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.

        Specified by:
        registerCacheEntryListener in interface ClientCache<K,​V>
        Parameters:
        cfg - a factory and related configuration for creating the listener.
        disconnectLsnr - Listener of client disconnected event.
        See Also:
        CacheEntryListener
      • deregisterCacheEntryListener

        public void deregisterCacheEntryListener​(javax.cache.configuration.CacheEntryListenerConfiguration<K,​V> cfg)
        Deregisters a listener, using the CacheEntryListenerConfiguration that was used to register it.
        Specified by:
        deregisterCacheEntryListener in interface ClientCache<K,​V>
        Parameters:
        cfg - the factory and related configuration that was used to create the listener.