Interface AsyncMap<K,​V>


  • public interface AsyncMap<K,​V>
    An asynchronous map.

    AsyncMap does not allow null to be used as a key or value.

    Author:
    Tim Fox
    • Method Detail

      • get

        Future<V> get​(K k)
        Get a value from the map, asynchronously.
        Parameters:
        k - the key
        Returns:
        a future notified some time later with the async result.
      • put

        Future<Void> put​(K k,
                         V v)
        Put a value in the map, asynchronously.
        Parameters:
        k - the key
        v - the value
        Returns:
        a future notified some time later with the async result.
      • put

        Future<Void> put​(K k,
                         V v,
                         long ttl)
        Like put(K, V) but specifying a time to live for the entry. Entry will expire and get evicted after the ttl.
        Parameters:
        k - the key
        v - the value
        ttl - The time to live (in ms) for the entry
        Returns:
        a future notified some time later with the async result.
      • putIfAbsent

        Future<V> putIfAbsent​(K k,
                              V v)
        Put the entry only if there is no entry with the key already present. If key already present then the existing value will be returned to the handler, otherwise null.
        Parameters:
        k - the key
        v - the value
        Returns:
        a future notified some time later with the async result.
      • putIfAbsent

        Future<V> putIfAbsent​(K k,
                              V v,
                              long ttl)
        Link putIfAbsent(K, V) but specifying a time to live for the entry. Entry will expire and get evicted after the ttl.
        Parameters:
        k - the key
        v - the value
        ttl - The time to live (in ms) for the entry
        Returns:
        a future notified some time later with the async result.
      • remove

        Future<V> remove​(K k)
        Remove a value from the map, asynchronously.
        Parameters:
        k - the key
        Returns:
        a future notified some time later with the async result.
      • removeIfPresent

        Future<Boolean> removeIfPresent​(K k,
                                        V v)
        Remove a value from the map, only if entry already exists with same value.
        Parameters:
        k - the key
        v - the value
        Returns:
        a future notified some time later with the async result.
      • replace

        Future<V> replace​(K k,
                          V v)
        Replace the entry only if it is currently mapped to some value
        Parameters:
        k - the key
        v - the new value
        Returns:
        a future notified some time later with the async result.
      • replace

        default Future<V> replace​(K k,
                                  V v,
                                  long ttl)
        Replace the entry only if it is currently mapped to some value
        Parameters:
        k - the key
        v - the new value
        ttl - The time to live (in ms) for the entry
        Returns:
        a future notified some time later with the previous value
      • replaceIfPresent

        Future<Boolean> replaceIfPresent​(K k,
                                         V oldValue,
                                         V newValue)
        Replace the entry only if it is currently mapped to a specific value
        Parameters:
        k - the key
        oldValue - the existing value
        newValue - the new value
        Returns:
        a future notified some time later with the async result.
      • replaceIfPresent

        default Future<Boolean> replaceIfPresent​(K k,
                                                 V oldValue,
                                                 V newValue,
                                                 long ttl)
        Replace the entry only if it is currently mapped to a specific value
        Parameters:
        k - the key
        oldValue - the existing value
        newValue - the new value
        ttl - The time to live (in ms) for the entry
        Returns:
        a future notified some time later with the async result.
      • clear

        Future<Void> clear()
        Clear all entries in the map
        Returns:
        a future notified some time later with the async result.
      • size

        Future<Integer> size()
        Provide the number of entries in the map
        Returns:
        a future notified some time later with the async result.
      • keys

        Future<Set<K>> keys()
        Get the keys of the map, asynchronously.

        Use this method with care as the map may contain a large number of keys, which may not fit entirely in memory of a single node. In this case, the invocation will result in an OutOfMemoryError.

        Returns:
        a future notified some time later with the async result.
      • values

        Future<List<V>> values()
        Get the values of the map, asynchronously.

        Use this method with care as the map may contain a large number of values, which may not fit entirely in memory of a single node. In this case, the invocation will result in an OutOfMemoryError.

        Returns:
        a future notified some time later with the async result.
      • entries

        Future<Map<K,​V>> entries()
        Get the entries of the map, asynchronously.

        Use this method with care as the map may contain a large number of entries, which may not fit entirely in memory of a single node. In this case, the invocation will result in an OutOfMemoryError.

        Returns:
        a future notified some time later with the async result.