Interface RedisSetCommands

All Known Subinterfaces:
DefaultedRedisClusterConnection, DefaultedRedisConnection, RedisClusterConnection, RedisCommands, RedisConnection, RedisConnectionUtils.RedisConnectionProxy, StringRedisConnection
All Known Implementing Classes:
AbstractRedisConnection, DefaultStringRedisConnection, JedisClusterConnection, JedisConnection, LettuceClusterConnection, LettuceConnection

public interface RedisSetCommands
Set-specific commands supported by Redis.
Author:
Costin Leau, Christoph Strobl, Mark Paluch
  • Method Summary

    Modifier and Type
    Method
    Description
    sAdd(byte[] key, byte[]... values)
    Add given values to set at key.
    sCard(byte[] key)
    Get size of set at key.
    Set<byte[]>
    sDiff(byte[]... keys)
    Diff all sets for given keys.
    sDiffStore(byte[] destKey, byte[]... keys)
    Diff all sets for given keys and store result in destKey.
    Set<byte[]>
    sInter(byte[]... keys)
    Returns the members intersecting all given sets at keys.
    sInterStore(byte[] destKey, byte[]... keys)
    Intersect all given sets at keys and store result in destKey.
    sIsMember(byte[] key, byte[] value)
    Check if set at key contains value.
    Set<byte[]>
    sMembers(byte[] key)
    Get all elements of set at key.
    sMIsMember(byte[] key, byte[]... values)
    Check if set at key contains one or more values.
    sMove(byte[] srcKey, byte[] destKey, byte[] value)
    Move value from srcKey to destKey
    byte[]
    sPop(byte[] key)
    Remove and return a random member from set at key.
    List<byte[]>
    sPop(byte[] key, long count)
    Remove and return count random members from set at key.
    byte[]
    sRandMember(byte[] key)
    Get random element from set at key.
    List<byte[]>
    sRandMember(byte[] key, long count)
    Get count random elements from set at key.
    sRem(byte[] key, byte[]... values)
    Remove given values from set at key and return the number of removed elements.
    Cursor<byte[]>
    sScan(byte[] key, ScanOptions options)
    Use a Cursor to iterate over elements in set at key.
    Set<byte[]>
    sUnion(byte[]... keys)
    Union all sets at given keys.
    sUnionStore(byte[] destKey, byte[]... keys)
    Union all sets at given keys and store result in destKey.
  • Method Details

    • sAdd

      @Nullable Long sAdd(byte[] key, byte[]... values)
      Add given values to set at key.
      Parameters:
      key - must not be null.
      values - must not be empty.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • sRem

      @Nullable Long sRem(byte[] key, byte[]... values)
      Remove given values from set at key and return the number of removed elements.
      Parameters:
      key - must not be null.
      values - must not be empty.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • sPop

      @Nullable byte[] sPop(byte[] key)
      Remove and return a random member from set at key.
      Parameters:
      key - must not be null.
      Returns:
      null when key does not exist or used in pipeline / transaction.
      See Also:
    • sPop

      @Nullable List<byte[]> sPop(byte[] 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:
      empty List if set does not exist. null when used in pipeline / transaction.
      Since:
      2.0
      See Also:
    • sMove

      @Nullable Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value)
      Move value from srcKey to destKey
      Parameters:
      srcKey - must not be null.
      destKey - must not be null.
      value - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • sCard

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

      @Nullable Boolean sIsMember(byte[] key, byte[] value)
      Check if set at key contains value.
      Parameters:
      key - must not be null.
      value - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • sMIsMember

      @Nullable List<Boolean> sMIsMember(byte[] key, byte[]... values)
      Check if set at key contains one or more values.
      Parameters:
      key - must not be null.
      values - must not be null.
      Returns:
      null when used in pipeline / transaction.
      Since:
      2.6
      See Also:
    • sDiff

      @Nullable Set<byte[]> sDiff(byte[]... keys)
      Diff all sets for given keys.
      Parameters:
      keys - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • sDiffStore

      @Nullable Long sDiffStore(byte[] destKey, byte[]... keys)
      Diff all sets for given keys and store result in destKey.
      Parameters:
      destKey - must not be null.
      keys - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • sInter

      @Nullable Set<byte[]> sInter(byte[]... keys)
      Returns the members intersecting all given sets at keys.
      Parameters:
      keys - must not be null.
      Returns:
      empty Set if no intersection found. null when used in pipeline / transaction.
      See Also:
    • sInterStore

      @Nullable Long sInterStore(byte[] destKey, byte[]... keys)
      Intersect all given sets at keys and store result in destKey.
      Parameters:
      destKey - must not be null.
      keys - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • sUnion

      @Nullable Set<byte[]> sUnion(byte[]... keys)
      Union all sets at given keys.
      Parameters:
      keys - must not be null.
      Returns:
      empty Set if keys do not exist. null when used in pipeline / transaction.
      See Also:
    • sUnionStore

      @Nullable Long sUnionStore(byte[] destKey, byte[]... keys)
      Union all sets at given keys and store result in destKey.
      Parameters:
      destKey - must not be null.
      keys - must not be null.
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • sMembers

      @Nullable Set<byte[]> sMembers(byte[] key)
      Get all elements of set at key.
      Parameters:
      key - must not be null.
      Returns:
      empty Set when key does not exist. null when used in pipeline / transaction.
      See Also:
    • sRandMember

      @Nullable byte[] sRandMember(byte[] key)
      Get random element from set at key.
      Parameters:
      key - must not be null.
      Returns:
      can be null.
      See Also:
    • sRandMember

      @Nullable List<byte[]> sRandMember(byte[] key, long count)
      Get count random elements from set at key.
      Parameters:
      key - must not be null.
      count -
      Returns:
      null when used in pipeline / transaction.
      See Also:
    • sScan

      Cursor<byte[]> sScan(byte[] key, ScanOptions options)
      Use a Cursor to iterate over elements in set at key.
      Parameters:
      key - must not be null.
      options - must not be null.
      Returns:
      never null.
      Since:
      1.4
      See Also: