Interface SetOperations<K,V>


public interface SetOperations<K,V>
Redis set specific operations.
Author:
Costin Leau, Christoph Strobl, Mark Paluch, Roman Bezpalko
  • Method Details

    • add

      @Nullable Long add(K key, V... values)
      Add given values to set at key.
      Parameters:
      key - must not be null.
      values -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • remove

      @Nullable Long remove(K key, Object... values)
      Remove given values from set at key and return the number of removed elements.
      Parameters:
      key - must not be null.
      values -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • pop

      @Nullable V pop(K key)
      Remove and return a random member from set at key.
      Parameters:
      key - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • pop

      @Nullable List<V> pop(K key, long count)
      Remove and return count random members from set at key.
      Parameters:
      key - must not be null.
      count - number of random members to pop from the set.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.0
      See Also:
    • move

      @Nullable Boolean move(K key, V value, K destKey)
      Move value from key to destKey
      Parameters:
      key - must not be null.
      value -
      destKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • size

      @Nullable Long size(K key)
      Get size of set at key.
      Parameters:
      key - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • isMember

      @Nullable Boolean isMember(K key, Object o)
      Check if set at key contains value.
      Parameters:
      key - must not be null.
      o -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • isMember

      @Nullable Map<Object,Boolean> isMember(K key, Object... objects)
      Check if set at key contains one or more values.
      Parameters:
      key - must not be null.
      objects -
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • intersect

      @Nullable Set<V> intersect(K key, K otherKey)
      Returns the members intersecting all given sets at key and otherKey.
      Parameters:
      key - must not be null.
      otherKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • intersect

      @Nullable Set<V> intersect(K key, Collection<K> otherKeys)
      Returns the members intersecting all given sets at key and otherKeys.
      Parameters:
      key - must not be null.
      otherKeys - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • intersect

      @Nullable Set<V> intersect(Collection<K> keys)
      Returns the members intersecting all given sets at keys.
      Parameters:
      keys - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.2
      See Also:
    • intersectAndStore

      @Nullable Long intersectAndStore(K key, K otherKey, K destKey)
      Intersect all given sets at key and otherKey and store result in destKey.
      Parameters:
      key - must not be null.
      otherKey - must not be null.
      destKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • intersectAndStore

      @Nullable Long intersectAndStore(K key, Collection<K> otherKeys, K destKey)
      Intersect all given sets at key and otherKeys and store result in destKey.
      Parameters:
      key - must not be null.
      otherKeys - must not be null.
      destKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • intersectAndStore

      @Nullable Long intersectAndStore(Collection<K> keys, K destKey)
      Intersect all given sets at keys and store result in destKey.
      Parameters:
      keys - must not be null.
      destKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.2
      See Also:
    • union

      @Nullable Set<V> union(K key, K otherKey)
      Union all sets at given keys and otherKey.
      Parameters:
      key - must not be null.
      otherKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • union

      @Nullable Set<V> union(K key, Collection<K> otherKeys)
      Union all sets at given keys and otherKeys.
      Parameters:
      key - must not be null.
      otherKeys - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • union

      @Nullable Set<V> union(Collection<K> keys)
      Union all sets at given keys.
      Parameters:
      keys - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.2
      See Also:
    • unionAndStore

      @Nullable Long unionAndStore(K key, K otherKey, K destKey)
      Union all sets at given key and otherKey and store result in destKey.
      Parameters:
      key - must not be null.
      otherKey - must not be null.
      destKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • unionAndStore

      @Nullable Long unionAndStore(K key, Collection<K> otherKeys, K destKey)
      Union all sets at given key and otherKeys and store result in destKey.
      Parameters:
      key - must not be null.
      otherKeys - must not be null.
      destKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • unionAndStore

      @Nullable Long unionAndStore(Collection<K> keys, K destKey)
      Union all sets at given keys and store result in destKey.
      Parameters:
      keys - must not be null.
      destKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.2
      See Also:
    • difference

      @Nullable Set<V> difference(K key, K otherKey)
      Diff all sets for given key and otherKey.
      Parameters:
      key - must not be null.
      otherKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • difference

      @Nullable Set<V> difference(K key, Collection<K> otherKeys)
      Diff all sets for given key and otherKeys.
      Parameters:
      key - must not be null.
      otherKeys - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • difference

      @Nullable Set<V> difference(Collection<K> keys)
      Diff all sets for given keys.
      Parameters:
      keys - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.2
      See Also:
    • differenceAndStore

      @Nullable Long differenceAndStore(K key, K otherKey, K destKey)
      Diff all sets for given key and otherKey and store result in destKey.
      Parameters:
      key - must not be null.
      otherKey - must not be null.
      destKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • differenceAndStore

      @Nullable Long differenceAndStore(K key, Collection<K> otherKeys, K destKey)
      Diff all sets for given key and otherKeys and store result in destKey.
      Parameters:
      key - must not be null.
      otherKeys - must not be null.
      destKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • differenceAndStore

      @Nullable Long differenceAndStore(Collection<K> keys, K destKey)
      Diff all sets for given keys and store result in destKey.
      Parameters:
      keys - must not be null.
      destKey - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.2
      See Also:
    • members

      @Nullable Set<V> members(K key)
      Get all elements of set at key.
      Parameters:
      key - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • randomMember

      V randomMember(K key)
      Get random element from set at key.
      Parameters:
      key - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • distinctRandomMembers

      @Nullable Set<V> distinctRandomMembers(K key, long count)
      Get count distinct random elements from set at key.
      Parameters:
      key - must not be null.
      count - nr of members to return
      Returns:
      empty Set if key does not exist.
      Throws:
      IllegalArgumentException - if count is negative.
      See Also:
    • randomMembers

      @Nullable List<V> randomMembers(K key, long count)
      Get count random elements from set at key.
      Parameters:
      key - must not be null.
      count - nr of members to return.
      Returns:
      empty List if key does not exist or null when used in pipeline / transaction.
      Throws:
      IllegalArgumentException - if count is negative.
      See Also:
    • scan

      Cursor<V> scan(K key, ScanOptions options)
      Use a Cursor to iterate over entries set at key.
      Important: Call CloseableIterator.close() when done to avoid resource leaks.
      Parameters:
      key -
      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<K,V> getOperations()