Interface SetCommands<K,V>

Type Parameters:
K - the type of the key
V - the type of the value stored in the sets
All Superinterfaces:
RedisCommands
All Known Implementing Classes:
BlockingSetCommandsImpl

public interface SetCommands<K,V> extends RedisCommands
Allows executing commands from the set group. See the set command list for further information about these commands.

A set is a set of value of type V.

  • Method Details

    • sadd

      int sadd(K key, V... values)
      Execute the command SADD. Summary: Add one or more members to a set Group: set Requires Redis 1.0.0
      Parameters:
      key - the key
      values - the values
      Returns:
      the number of elements that were added to the set, not including all the elements already present in the set.
    • scard

      long scard(K key)
      Execute the command SCARD. Summary: Get the number of members in a set Group: set Requires Redis 1.0.0
      Parameters:
      key - the key
      Returns:
      the cardinality (number of elements) of the set, or 0 key does not exist.
    • sdiff

      Set<V> sdiff(K... keys)
      Execute the command SDIFF. Summary: Subtract multiple sets Group: set Requires Redis 1.0.0
      Parameters:
      keys - the keys
      Returns:
      list with members of the resulting set.
    • sdiffstore

      long sdiffstore(K destination, K... keys)
      Execute the command SDIFFSTORE. Summary: Subtract multiple sets and store the resulting set in a key Group: set Requires Redis 1.0.0
      Parameters:
      destination - the key
      keys - the keys
      Returns:
      the number of elements in the resulting set.
    • sinter

      Set<V> sinter(K... keys)
      Execute the command SINTER. Summary: Intersect multiple sets Group: set Requires Redis 1.0.0
      Parameters:
      keys - the keys
      Returns:
      list with members of the resulting set.
    • sintercard

      long sintercard(K... keys)
      Execute the command SINTERCARD. Summary: Intersect multiple sets and return the cardinality of the result Group: set Requires Redis 7.0.0
      Parameters:
      keys - the keys
      Returns:
      the number of elements in the resulting intersection.
    • sintercard

      long sintercard(int limit, K... keys)
      Execute the command SINTERCARD. Summary: Intersect multiple sets and return the cardinality of the result Group: set Requires Redis 7.0.0
      Parameters:
      limit - When provided with the optional LIMIT argument (which defaults to 0 and means unlimited), if the intersection cardinality reaches limit partway through the computation, the algorithm will exit and yield limit as the cardinality.
      keys - the keys
      Returns:
      the number of elements in the resulting intersection.
    • sinterstore

      long sinterstore(K destination, K... keys)
      Execute the command SINTERSTORE. Summary: Intersect multiple sets and store the resulting set in a key Group: set Requires Redis 1.0.0
      Parameters:
      destination - the key
      keys - the keys
      Returns:
      the number of elements in the resulting set.
    • sismember

      boolean sismember(K key, V member)
      Execute the command SISMEMBER. Summary: Determine if a given value is a member of a set Group: set Requires Redis 1.0.0
      Parameters:
      key - the key
      member - the member to check
      Returns:
      true the element is a member of the set. false the element is not a member of the set, or if key does not exist.
    • smembers

      Set<V> smembers(K key)
      Execute the command SMEMBERS. Summary: Get all the members in a set Group: set Requires Redis 1.0.0
      Parameters:
      key - the key
      Returns:
      all elements of the set.
    • smismember

      List<Boolean> smismember(K key, V... members)
      Execute the command SMISMEMBER. Summary: Returns the membership associated with the given elements for a set Group: set Requires Redis 6.2.0
      Parameters:
      key - the key
      members - the members to check
      Returns:
      list representing the membership of the given elements, in the same order as they are requested.
    • smove

      boolean smove(K source, K destination, V member)
      Execute the command SMOVE. Summary: Move a member from one set to another Group: set Requires Redis 1.0.0
      Parameters:
      source - the key
      destination - the key
      member - the member to move
      Returns:
      true the element is moved. false the element is not a member of source and no operation was performed.
    • spop

      V spop(K key)
      Execute the command SPOP. Summary: Remove and return one or multiple random members from a set Group: set Requires Redis 1.0.0
      Parameters:
      key - the key
      Returns:
      the removed member, or null when key does not exist.
    • spop

      Set<V> spop(K key, int count)
      Execute the command SPOP. Summary: Remove and return one or multiple random members from a set Group: set Requires Redis 1.0.0
      Parameters:
      key - the key
      Returns:
      the removed members, or an empty array when key does not exist.
    • srandmember

      V srandmember(K key)
      Execute the command SRANDMEMBER. Summary: Get one or multiple random members from a set Group: set Requires Redis 1.0.0
      Parameters:
      key - the key
      Returns:
      the randomly selected element, or null when key does not exist.
    • srandmember

      List<V> srandmember(K key, int count)
      Execute the command SRANDMEMBER. Summary: Get one or multiple random members from a set Group: set Requires Redis 1.0.0
      Parameters:
      key - the key
      count - the number of elements to pick
      Returns:
      an array of elements, or an empty array when key does not exist.
    • srem

      int srem(K key, V... members)
      Execute the command SREM. Summary: Remove one or more members from a set Group: set Requires Redis 1.0.0
      Parameters:
      key - the key
      Returns:
      the number of members that were removed from the set, not including non-existing members.
    • sunion

      Set<V> sunion(K... keys)
      Execute the command SUNION. Summary: Add multiple sets Group: set Requires Redis 1.0.0
      Parameters:
      keys - the keys
      Returns:
      list with members of the resulting set.
    • sunionstore

      long sunionstore(K destination, K... keys)
      Execute the command SUNIONSTORE. Summary: Add multiple sets and store the resulting set in a key Group: set Requires Redis 1.0.0
      Parameters:
      destination - the destination key
      keys - the keys
      Returns:
      the number of elements in the resulting set.
    • sscan

      SScanCursor<V> sscan(K key)
      Execute the command SSCAN. Summary: Incrementally iterate Set elements Group: set Requires Redis 2.8.0
      Parameters:
      key - the key
      Returns:
      the cursor
    • sscan

      SScanCursor<V> sscan(K key, ScanArgs scanArgs)
      Execute the command SSCAN. Summary: Incrementally iterate Set elements Group: set Requires Redis 2.8.0
      Parameters:
      key - the key
      scanArgs - the extra parameters
      Returns:
      the cursor
    • sort

      List<V> sort(K key)
      Execute the command SORT. Summary: Sort the elements in a list, set or sorted set Group: generic Requires Redis 1.0.0
      Returns:
      the list of sorted elements.
    • sort

      List<V> sort(K key, SortArgs sortArguments)
      Execute the command SORT. Summary: Sort the elements in a list, set or sorted set Group: generic Requires Redis 1.0.0
      Parameters:
      key - the key
      sortArguments - the SORT command extra-arguments
      Returns:
      the list of sorted elements.
    • sortAndStore

      long sortAndStore(K key, K destination, SortArgs sortArguments)
      Execute the command SORT with the STORE option. Summary: Sort the elements in a list, set or sorted set Group: generic Requires Redis 1.0.0
      Parameters:
      sortArguments - the SORT command extra-arguments
      Returns:
      the number of sorted elements in the destination list.
    • sortAndStore

      long sortAndStore(K key, K destination)
      Execute the command SORT with the STORE option. Summary: Sort the elements in a list, set or sorted set Group: generic Requires Redis 1.0.0
      Returns:
      the number of sorted elements in the destination list.