io.vertx.core.shareddata

## 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 Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `Future<Void>` | `clear()` Same as `clear(Handler)` but returns a `Future` of the asynchronous result
    `default void` | `clear(Handler<AsyncResult<Void>> resultHandler)` Clear all entries in the map
    `Future<Map<K,V>>` | `entries()` Same as `entries(Handler)` but returns a `Future` of the asynchronous result
    `default void` | `entries(Handler<AsyncResult<Map<K,V>>> resultHandler)` Get the entries of the map, asynchronously.
    `Future<V>` | `get(K k)` Same as `#get(K, Handler)` but returns a `Future` of the asynchronous result
    `default void` | `get(K k, Handler<AsyncResult<V>> resultHandler)` Get a value from the map, asynchronously.
    `Future<Set<K>>` | `keys()` Same as `keys(Handler)` but returns a `Future` of the asynchronous result
    `default void` | `keys(Handler<AsyncResult<Set<K>>> resultHandler)` Get the keys of the map, asynchronously.
    `Future<Void>` | `put(K k, V v)` Same as `#put(K, V, Handler)` but returns a `Future` of the asynchronous result
    `default void` | `put(K k, V v, Handler<AsyncResult<Void>> completionHandler)` Put a value in the map, asynchronously.
    `Future<Void>` | `put(K k, V v, long ttl)` Same as `#put(K, V, long, Handler)` but returns a `Future` of the asynchronous result
    `default void` | `put(K k, V v, long ttl, Handler<AsyncResult<Void>> completionHandler)` Like `put(K, V, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)` but specifying a time to live for the entry.
    `Future<V>` | `putIfAbsent(K k, V v)` Same as `#putIfAbsent(K, V, Handler)` but returns a `Future` of the asynchronous result
    `default void` | `putIfAbsent(K k, V v, Handler<AsyncResult<V>> completionHandler)` Put the entry only if there is no entry with the key already present.
    `Future<V>` | `putIfAbsent(K k, V v, long ttl)` Same as `#putIfAbsent(K, V, long, Handler)` but returns a `Future` of the asynchronous result
    `default void` | `putIfAbsent(K k, V v, long ttl, Handler<AsyncResult<V>> completionHandler)` Link `putIfAbsent(K, V, io.vertx.core.Handler<io.vertx.core.AsyncResult<V>>)` but specifying a time to live for the entry.
    `Future<V>` | `remove(K k)` Same as `#remove(K, Handler)` but returns a `Future` of the asynchronous result
    `default void` | `remove(K k, Handler<AsyncResult<V>> resultHandler)` Remove a value from the map, asynchronously.
    `Future<Boolean>` | `removeIfPresent(K k, V v)` Same as `#removeIfPresent(K, V, Handler)` but returns a `Future` of the asynchronous result
    `default void` | `removeIfPresent(K k, V v, Handler<AsyncResult<Boolean>> resultHandler)` Remove a value from the map, only if entry already exists with same value.
    `Future<V>` | `replace(K k, V v)` Same as `#replace(K, V, Handler)` but returns a `Future` of the asynchronous result
    `default void` | `replace(K k, V v, Handler<AsyncResult<V>> resultHandler)` Replace the entry only if it is currently mapped to some value
    `default Future<V>` | `replace(K k, V v, long ttl)` Same as `#replace(K, V, long, Handler)` but returns a `Future` of the asynchronous result returns UnsupportedOperationException if the implementation does not support it
    `default void` | `replace(K k, V v, long ttl, Handler<AsyncResult<V>> resultHandler)` Replace the entry only if it is currently mapped to some value
    `Future<Boolean>` | `replaceIfPresent(K k, V oldValue, V newValue)` Same as `#replaceIfPresent(K, V, V, Handler)` but returns a `Future` of the asynchronous result
    `default void` | `replaceIfPresent(K k, V oldValue, V newValue, Handler<AsyncResult<Boolean>> resultHandler)` Replace the entry only if it is currently mapped to a specific value
    `default Future<Boolean>` | `replaceIfPresent(K k, V oldValue, V newValue, long ttl)` Same as `#replaceIfPresent(K, V, V, long, Handler)` but returns a `Future` of the asynchronous result returns UnsupportedOperationException if the implementation does not support it
    `default void` | `replaceIfPresent(K k, V oldValue, V newValue, long ttl, Handler<AsyncResult<Boolean>> resultHandler)` Replace the entry only if it is currently mapped to a specific value
    `Future<Integer>` | `size()` Same as `size(Handler)` but returns a `Future` of the asynchronous result
    `default void` | `size(Handler<AsyncResult<Integer>> resultHandler)` Provide the number of entries in the map
    `Future<List<V>>` | `values()` Same as `values(Handler)` but returns a `Future` of the asynchronous result
    `default void` | `values(Handler<AsyncResult<List<V>>> resultHandler)` Get the values of the map, asynchronously.

- - ### Method Detail

    - #### get

          default void get(K k,
                           Handler<AsyncResult<V>> resultHandler)

      Get a value from the map, asynchronously.
      Parameters:
        `k` - the key
        `resultHandler` - - this will be called some time later with the async result.

    - #### get

          Future<V> get(K k)

      Same as `#get(K, Handler)` but returns a `Future` of the asynchronous result

    - #### put

          default void put(K k,
                           V v,
                           Handler<AsyncResult<Void>> completionHandler)

      Put a value in the map, asynchronously.
      Parameters:
        `k` - the key
        `v` - the value
        `completionHandler` - - this will be called some time later to signify the value has been put

    - #### put

          Future<Void> put(K k,
                           V v)

      Same as `#put(K, V, Handler)` but returns a `Future` of the asynchronous result

    - #### put

          default void put(K k,
                           V v,
                           long ttl,
                           Handler<AsyncResult<Void>> completionHandler)

      Like `put(K, V, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)` 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
        `completionHandler` - the handler

    - #### put

          Future<Void> put(K k,
                           V v,
                           long ttl)

      Same as `#put(K, V, long, Handler)` but returns a `Future` of the asynchronous result

    - #### putIfAbsent

          default void putIfAbsent(K k,
                                   V v,
                                   Handler<AsyncResult<V>> completionHandler)

      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
        `completionHandler` - the handler

    - #### putIfAbsent

          Future<V> putIfAbsent(K k,
                                V v)

      Same as `#putIfAbsent(K, V, Handler)` but returns a `Future` of the asynchronous result

    - #### putIfAbsent

          default void putIfAbsent(K k,
                                   V v,
                                   long ttl,
                                   Handler<AsyncResult<V>> completionHandler)

      Link `putIfAbsent(K, V, io.vertx.core.Handler<io.vertx.core.AsyncResult<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
        `completionHandler` - the handler

    - #### putIfAbsent

          Future<V> putIfAbsent(K k,
                                V v,
                                long ttl)

      Same as `#putIfAbsent(K, V, long, Handler)` but returns a `Future` of the asynchronous result

    - #### remove

          default void remove(K k,
                              Handler<AsyncResult<V>> resultHandler)

      Remove a value from the map, asynchronously.
      Parameters:
        `k` - the key
        `resultHandler` - - this will be called some time later to signify the value has been removed

    - #### remove

          Future<V> remove(K k)

      Same as `#remove(K, Handler)` but returns a `Future` of the asynchronous result

    - #### removeIfPresent

          default void removeIfPresent(K k,
                                       V v,
                                       Handler<AsyncResult<Boolean>> resultHandler)

      Remove a value from the map, only if entry already exists with same value.
      Parameters:
        `k` - the key
        `v` - the value
        `resultHandler` - - this will be called some time later to signify the value has been removed

    - #### removeIfPresent

          Future<Boolean> removeIfPresent(K k,
                                          V v)

      Same as `#removeIfPresent(K, V, Handler)` but returns a `Future` of the asynchronous result

    - #### replace

          default void replace(K k,
                               V v,
                               Handler<AsyncResult<V>> resultHandler)

      Replace the entry only if it is currently mapped to some value
      Parameters:
        `k` - the key
        `v` - the new value
        `resultHandler` - the result handler will be passed the previous value

    - #### replace

          Future<V> replace(K k,
                            V v)

      Same as `#replace(K, V, Handler)` but returns a `Future` of the asynchronous result

    - #### replace

          default void replace(K k,
                               V v,
                               long ttl,
                               Handler<AsyncResult<V>> resultHandler)

      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
        `resultHandler` - the result handler will be passed the previous value

    - #### replace

          default Future<V> replace(K k,
                                    V v,
                                    long ttl)

      Same as `#replace(K, V, long, Handler)` but returns a `Future` of the asynchronous result returns UnsupportedOperationException if the implementation does not support it

    - #### replaceIfPresent

          default void replaceIfPresent(K k,
                                        V oldValue,
                                        V newValue,
                                        Handler<AsyncResult<Boolean>> resultHandler)

      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
        `resultHandler` - the result handler

    - #### replaceIfPresent

          Future<Boolean> replaceIfPresent(K k,
                                           V oldValue,
                                           V newValue)

      Same as `#replaceIfPresent(K, V, V, Handler)` but returns a `Future` of the asynchronous result

    - #### replaceIfPresent

          default void replaceIfPresent(K k,
                                        V oldValue,
                                        V newValue,
                                        long ttl,
                                        Handler<AsyncResult<Boolean>> resultHandler)

      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
        `resultHandler` - the result handler

    - #### replaceIfPresent

          default Future<Boolean> replaceIfPresent(K k,
                                                   V oldValue,
                                                   V newValue,
                                                   long ttl)

      Same as `#replaceIfPresent(K, V, V, long, Handler)` but returns a `Future` of the asynchronous result returns UnsupportedOperationException if the implementation does not support it

    - #### clear

          default void clear(Handler<AsyncResult<Void>> resultHandler)

      Clear all entries in the map
      Parameters:
        `resultHandler` - called on completion

    - #### clear

          Future<Void> clear()

      Same as `clear(Handler)` but returns a `Future` of the asynchronous result

    - #### size

          default void size(Handler<AsyncResult<Integer>> resultHandler)

      Provide the number of entries in the map
      Parameters:
        `resultHandler` - handler which will receive the number of entries

    - #### size

          Future<Integer> size()

      Same as `size(Handler)` but returns a `Future` of the asynchronous result

    - #### keys

          default void keys(Handler<AsyncResult<Set<K>>> resultHandler)

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

      Parameters:
        `resultHandler` - invoked when the operation completes

    - #### keys

          Future<Set<K>> keys()

      Same as `keys(Handler)` but returns a `Future` of the asynchronous result

    - #### values

          default void values(Handler<AsyncResult<List<V>>> resultHandler)

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

      Parameters:
        `resultHandler` - invoked when the operation completes

    - #### values

          Future<List<V>> values()

      Same as `values(Handler)` but returns a `Future` of the asynchronous result

    - #### entries

          default void entries(Handler<AsyncResult<Map<K,V>>> resultHandler)

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

      Parameters:
        `resultHandler` - invoked when the operation completes

    - #### entries

          Future<Map<K,V>> entries()

      Same as `entries(Handler)` but returns a `Future` of the asynchronous result

Copyright © 2024 Eclipse. All rights reserved.