Interface ReactiveHashOperations<H,HK,HV>


public interface ReactiveHashOperations<H,HK,HV>
Reactive Redis operations for Hash Commands.

Streams of methods returning Mono<K> or Flux<M> are terminated with InvalidDataAccessApiUsageException when RedisElementReader.read(ByteBuffer) returns null for a particular element as Reactive Streams prohibit the usage of null values.

Since:
2.0
Author:
Mark Paluch, Christoph Strobl
  • Method Details

    • remove

      Mono<Long> remove(H key, Object... hashKeys)
      Delete given hash hashKeys from the hash at key.
      Parameters:
      key - must not be null.
      hashKeys - must not be null.
      Returns:
    • hasKey

      Mono<Boolean> hasKey(H key, Object hashKey)
      Determine if given hash hashKey exists.
      Parameters:
      key - must not be null.
      hashKey - must not be null.
      Returns:
    • get

      Mono<HV> get(H key, Object hashKey)
      Get value for given hashKey from hash at key.
      Parameters:
      key - must not be null.
      hashKey - must not be null.
      Returns:
    • multiGet

      Mono<List<HV>> multiGet(H key, Collection<HK> hashKeys)
      Get values for given hashKeys from hash at key. Values are in the order of the requested keys. Absent field values are represented using null in the resulting List.
      Parameters:
      key - must not be null.
      hashKeys - must not be null.
      Returns:
    • increment

      Mono<Long> increment(H key, HK hashKey, long delta)
      Increment value of a hash hashKey by the given delta.
      Parameters:
      key - must not be null.
      hashKey - must not be null.
      delta -
      Returns:
    • increment

      Mono<Double> increment(H key, HK hashKey, double delta)
      Increment value of a hash hashKey by the given delta.
      Parameters:
      key - must not be null.
      hashKey - must not be null.
      delta -
      Returns:
    • randomKey

      Mono<HK> randomKey(H key)
      Return a random hash key from the hash stored at key.
      Parameters:
      key - must not be null.
      Returns:
      Since:
      2.6
      See Also:
    • randomEntry

      Mono<Map.Entry<HK,HV>> randomEntry(H key)
      Return a random entry from the hash stored at key.
      Parameters:
      key - must not be null.
      Returns:
      Since:
      2.6
      See Also:
    • randomKeys

      Flux<HK> randomKeys(H key, long count)
      Return random hash keys from the hash stored at key. If the provided count argument is positive, return a list of distinct hash keys, capped either at count or the hash size. If count is negative, the behavior changes and the command is allowed to return the same hash key multiple times. In this case, the number of returned fields is the absolute value of the specified count.
      Parameters:
      key - must not be null.
      count - number of fields to return.
      Returns:
      Since:
      2.6
      See Also:
    • randomEntries

      Flux<Map.Entry<HK,HV>> randomEntries(H key, long count)
      Return random entries from the hash stored at key. If the provided count argument is positive, return a list of distinct entries, capped either at count or the hash size. If count is negative, the behavior changes and the command is allowed to return the same entry multiple times. In this case, the number of returned fields is the absolute value of the specified count.
      Parameters:
      key - must not be null.
      count - number of fields to return.
      Returns:
      null if key does not exist or when used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • keys

      Flux<HK> keys(H key)
      Get key set (fields) of hash at key.
      Parameters:
      key - must not be null.
      Returns:
    • size

      Mono<Long> size(H key)
      Get size of hash at key.
      Parameters:
      key - must not be null.
      Returns:
    • putAll

      Mono<Boolean> putAll(H key, Map<? extends HK,? extends HV> map)
      Set multiple hash fields to multiple values using data provided in m.
      Parameters:
      key - must not be null.
      map - must not be null.
    • put

      Mono<Boolean> put(H key, HK hashKey, HV value)
      Set the value of a hash hashKey.
      Parameters:
      key - must not be null.
      hashKey - must not be null.
      value -
    • putIfAbsent

      Mono<Boolean> putIfAbsent(H key, HK hashKey, HV value)
      Set the value of a hash hashKey only if hashKey does not exist.
      Parameters:
      key - must not be null.
      hashKey - must not be null.
      value -
      Returns:
    • values

      Flux<HV> values(H key)
      Get entry set (values) of hash at key.
      Parameters:
      key - must not be null.
      Returns:
    • entries

      Flux<Map.Entry<HK,HV>> entries(H key)
      Get entire hash stored at key.
      Parameters:
      key - must not be null.
      Returns:
    • scan

      default Flux<Map.Entry<HK,HV>> scan(H key)
      Use a Flux to iterate over entries in the hash at key. The resulting Flux acts as a cursor and issues HSCAN commands itself as long as the subscriber signals demand.
      Parameters:
      key - must not be null.
      Returns:
      the Flux emitting the entries on by one or an empty flux if the key does not exist.
      Throws:
      IllegalArgumentException - when the given key is null.
      Since:
      2.1
      See Also:
    • scan

      Flux<Map.Entry<HK,HV>> scan(H key, ScanOptions options)
      Use a Flux to iterate over entries in the hash at key given ScanOptions. The resulting Flux acts as a cursor and issues HSCAN commands itself as long as the subscriber signals demand.
      Parameters:
      key - must not be null.
      options - must not be null. Use ScanOptions.NONE instead.
      Returns:
      the Flux emitting the entries on by one or an empty flux if the key does not exist.
      Throws:
      IllegalArgumentException - when one of the required arguments is null.
      Since:
      2.1
      See Also:
    • expire

      Mono<ExpireChanges<HK>> expire(H key, Duration timeout, Collection<HK> hashKeys)
      Set time to live for given hashKeys stored within key.
      Parameters:
      key - must not be null.
      timeout - the amount of time after which the key will be expired, must not be null.
      hashKeys - must not be null.
      Returns:
      a Mono emitting changes to the hash fields.
      Throws:
      IllegalArgumentException - if the timeout is null.
      Since:
      3.5
      See Also:
    • expire

      Mono<ExpireChanges<HK>> expire(H key, Expiration expiration, ExpirationOptions options, Collection<HK> hashKeys)
      Set time to live for given hashKeys stored within key.
      Parameters:
      key - must not be null.
      expiration - must not be null.
      options - additional options to apply.
      hashKeys - must not be null.
      Returns:
      a Mono emitting changes to the hash fields.
      Throws:
      IllegalArgumentException - if the timeout is null.
      Since:
      3.5
      See Also:
    • expireAt

      @Nullable Mono<ExpireChanges<HK>> expireAt(H key, Instant expireAt, Collection<HK> hashKeys)
      Set the expiration for given hashKey as a date timestamp.
      Parameters:
      key - must not be null.
      expireAt - must not be null.
      hashKeys - must not be null.
      Returns:
      a Mono emitting changes to the hash fields.
      Throws:
      IllegalArgumentException - if the instant is null or too large to represent as a Date.
      Since:
      3.5
      See Also:
    • persist

      @Nullable Mono<ExpireChanges<HK>> persist(H key, Collection<HK> hashKeys)
      Remove the expiration from given hashKey .
      Parameters:
      key - must not be null.
      hashKeys - must not be null.
      Returns:
      a Mono emitting changes to the hash fields.
      Since:
      3.5
      See Also:
    • getTimeToLive

      @Nullable default Mono<Expirations<HK>> getTimeToLive(H key, Collection<HK> hashKeys)
      Get the time to live for hashKey in seconds.
      Parameters:
      key - must not be null.
      hashKeys - must not be null.
      Returns:
      a Mono emitting Expirations of the hash fields.
      Since:
      3.5
      See Also:
    • getTimeToLive

      @Nullable Mono<Expirations<HK>> getTimeToLive(H key, TimeUnit timeUnit, Collection<HK> hashKeys)
      Get the time to live for hashKey and convert it to the given TimeUnit.
      Parameters:
      key - must not be null.
      timeUnit - must not be null.
      hashKeys - must not be null.
      Returns:
      a Mono emitting Expirations of the hash fields.
      Since:
      3.5
      See Also:
    • delete

      Mono<Boolean> delete(H key)
      Removes the given key.
      Parameters:
      key - must not be null.