Interface AsyncStorage<Value extends Storable>

All Known Implementing Classes:
ElasticMap, HazelMap, IndexedMap, IndexedMapPersisted, IndexedMapVolatile, JsonMap, MongoDBMap, PrivateMap, SharedMap

public interface AsyncStorage<Value extends Storable>
Reuses the AsyncMap interface from hazelcast.

Storages implementing this class are recommended to create an index for attributes that are queried. It is highly recommended to create an index for the ID field, which is used by all Storable classes.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addIndex​(String field)
     
    void
    clear​(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
    removes all existing entries from the storage.
    default void
    contains​(String key, io.vertx.core.Handler<io.vertx.core.AsyncResult<Boolean>> handler)
    checks if an entry exists for the given key
    Get the context for the storage.
    void
    get​(String key, io.vertx.core.Handler<io.vertx.core.AsyncResult<Value>> handler)
    get an entry with the given key, if the key does not match a value fails with #ValueMissingException
    void
    put​(Value value, io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
    set the entry identified by the given key to the given value
    void
    putIfAbsent​(Value value, io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
    set the entry if it does not already exists.
    initialize the construction of a query.
    query​(String attribute)
    Creates a new query on the specified attribute.
    void
    remove​(String key, io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
    Removes an entry by its key.
    void
    size​(io.vertx.core.Handler<io.vertx.core.AsyncResult<Integer>> handler)
    returns the amount of entries in the storage.
    void
    update​(Value value, io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
    updates the value of the given key if a value already exists.
    void
    values​(io.vertx.core.Handler<io.vertx.core.AsyncResult<Stream<Value>>> handler)
    Get all values contained within the storage as a stream.
  • Method Details

    • get

      void get(String key, io.vertx.core.Handler<io.vertx.core.AsyncResult<Value>> handler)
      get an entry with the given key, if the key does not match a value fails with #ValueMissingException
      Parameters:
      key - a unique key identifying an entry
      handler - callback
    • contains

      default void contains(String key, io.vertx.core.Handler<io.vertx.core.AsyncResult<Boolean>> handler)
      checks if an entry exists for the given key
      Parameters:
      key - the key to check if set
      handler - callback
    • put

      void put(Value value, io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
      set the entry identified by the given key to the given value
      Parameters:
      value - the value to be set for the given key
      handler - callback
    • putIfAbsent

      void putIfAbsent(Value value, io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
      set the entry if it does not already exists. fails with #ValueAlreadyPresentException if the key already has a value.
      Parameters:
      value - the value to be set if the entry does not exist.
      handler - callback
    • remove

      void remove(String key, io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
      Removes an entry by its key.
      Parameters:
      key - identifies the entry to be removed.
      handler - callback
    • update

      void update(Value value, io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
      updates the value of the given key if a value already exists.
      Parameters:
      value - the new value of the entry
      handler - callback
    • values

      void values(io.vertx.core.Handler<io.vertx.core.AsyncResult<Stream<Value>>> handler)
      Get all values contained within the storage as a stream. Not recommended to use on large maps.
      Parameters:
      handler - callback
    • clear

      void clear(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
      removes all existing entries from the storage.
      Parameters:
      handler - callback
    • size

      void size(io.vertx.core.Handler<io.vertx.core.AsyncResult<Integer>> handler)
      returns the amount of entries in the storage.
      Parameters:
      handler - callback
    • context

      StorageContext<Value> context()
      Get the context for the storage.
      Returns:
      a storage context.
    • addIndex

      void addIndex(String field)
      Parameters:
      field - the path to the attribute to index, must include the array token in #CoreStrings.STORAGE_ARRAY.
    • query

      initialize the construction of a query.
      Returns:
      a builder String for constructing the query.
    • query

      default QueryBuilder<Value> query(String attribute)
      Creates a new query on the specified attribute.
      Parameters:
      attribute - the attribute to query.
      Returns:
      a new query builder.