io.vertx.core.shareddata

## Interface AsyncMap<K,V>

-     public interface AsyncMap<K,V>

  An asynchronous map.

  Author:
    Tim Fox

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear(Handler<AsyncResult<Void>> resultHandler)` Clear all entries in the map
    `void` | `entries(Handler<AsyncResult<Map<K,V>>> resultHandler)` Get the entries of the map, asynchronously.
    `void` | `get(K k, Handler<AsyncResult<V>> resultHandler)` Get a value from the map, asynchronously.
    `void` | `keys(Handler<AsyncResult<Set<K>>> resultHandler)` Get the keys of the map, asynchronously.
    `void` | `put(K k, V v, Handler<AsyncResult<Void>> completionHandler)` Put a value in the map, asynchronously.
    `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.
    `void` | `putIfAbsent(K k, V v, Handler<AsyncResult<V>> completionHandler)` Put the entry only if there is no entry with the key already present.
    `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.
    `void` | `remove(K k, Handler<AsyncResult<V>> resultHandler)` Remove a value from the map, asynchronously.
    `void` | `removeIfPresent(K k, V v, Handler<AsyncResult<Boolean>> resultHandler)` Remove a value from the map, only if entry already exists with same value.
    `void` | `replace(K k, V v, Handler<AsyncResult<V>> resultHandler)` Replace the entry only if it is currently mapped to some value
    `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
    `void` | `size(Handler<AsyncResult<Integer>> resultHandler)` Provide the number of entries in the map
    `void` | `values(Handler<AsyncResult<List<V>>> resultHandler)` Get the values of the map, asynchronously.

- - ### Method Detail

    - #### get

          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.

    - #### put

          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

          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

    - #### putIfAbsent

          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

          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

    - #### remove

          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

    - #### removeIfPresent

          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

    - #### replace

          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

    - #### replaceIfPresent

          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

    - #### clear

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

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

    - #### size

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

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

    - #### keys

          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

    - #### values

          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

    - #### entries

          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

Copyright © 2017. All rights reserved.