Interface HashOperations<H,HK,HV>


public interface HashOperations<H,HK,HV>
Redis map specific operations working on a hash.
Author:
Costin Leau, Christoph Strobl, Ninad Divadkar
  • Method Details

    • delete

      Long delete(H key, Object... hashKeys)
      Delete given hash hashKeys.
      Parameters:
      key - must not be null.
      hashKeys - must not be null.
      Returns:
      null when used in pipeline / transaction.
    • hasKey

      Boolean hasKey(H key, Object hashKey)
      Determine if given hash hashKey exists.
      Parameters:
      key - must not be null.
      hashKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
    • get

      @Nullable 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:
      null when key or hashKey does not exist or used in pipeline / transaction.
    • multiGet

      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:
      null when used in pipeline / transaction.
    • increment

      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:
      null when used in pipeline / transaction.
    • increment

      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:
      null when used in pipeline / transaction.
    • randomKey

      @Nullable HK randomKey(H key)
      Return a random hash key (aka field) from the hash stored at key.
      Parameters:
      key - must not be null.
      Returns:
      null if key does not exist or when used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • randomEntry

      @Nullable Map.Entry<HK,HV> randomEntry(H key)
      Return a random entry from the hash stored at key.
      Parameters:
      key - must not be null.
      Returns:
      null if key does not exist or when used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • randomKeys

      @Nullable List<HK> randomKeys(H key, long count)
      Return random hash keys (aka fields) 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:
      null if key does not exist or when used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • randomEntries

      @Nullable Map<HK,HV> randomEntries(H key, long count)
      Return a random entries from the hash stored at key.
      Parameters:
      key - must not be null.
      count - number of fields to return. Must be positive.
      Returns:
      null if key does not exist or when used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • keys

      Set<HK> keys(H key)
      Get key set (fields) of hash at key.
      Parameters:
      key - must not be null.
      Returns:
      null when used in pipeline / transaction.
    • lengthOfValue

      @Nullable Long lengthOfValue(H key, HK hashKey)
      Returns the length of the value associated with hashKey. If either the key or the hashKey do not exist, 0 is returned.
      Parameters:
      key - must not be null.
      hashKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.1
    • size

      Long size(H key)
      Get size of hash at key.
      Parameters:
      key - must not be null.
      Returns:
      null when used in pipeline / transaction.
    • putAll

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

      void 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

      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:
      null when used in pipeline / transaction.
    • values

      List<HV> values(H key)
      Get entry set (values) of hash at key.
      Parameters:
      key - must not be null.
      Returns:
      null when used in pipeline / transaction.
    • entries

      Map<HK,HV> entries(H key)
      Get entire hash stored at key.
      Parameters:
      key - must not be null.
      Returns:
      null when used in pipeline / transaction.
    • scan

      Cursor<Map.Entry<HK,HV>> scan(H key, ScanOptions options)
      Use a Cursor to iterate over entries in hash at key.
      Important: Call CloseableIterator.close() when done to avoid resource leaks.
      Parameters:
      key - must not be null.
      options - must not be null.
      Returns:
      the result cursor providing access to the scan result. Must be closed once fully processed (e.g. through a try-with-resources clause).
      Since:
      1.4
    • getOperations

      RedisOperations<H,?> getOperations()
      Returns:
      never null.