Interface RedisSetCommands

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

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

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

    • sAdd

      Long sAdd(byte @NonNull [] key, byte @NonNull [] @NonNull ... 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

      Long sRem(byte @NonNull [] key, byte[] @NonNull ... 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

      byte[] sPop(byte @NonNull [] 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

      List<byte @NonNull []> sPop(byte @NonNull [] 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

      Boolean sMove(byte @NonNull [] srcKey, byte @NonNull [] destKey, byte @NonNull [] 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

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

      Boolean sIsMember(byte @NonNull [] key, byte @NonNull [] 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

      List<@NonNull Boolean> sMIsMember(byte @NonNull [] key, byte @NonNull [] @NonNull ... 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

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

      Long sDiffStore(byte @NonNull [] destKey, byte @NonNull [] @NonNull ... 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

      Set<byte @NonNull []> sInter(byte @NonNull [] @NonNull ... 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

      Long sInterStore(byte @NonNull [] destKey, byte @NonNull [] @NonNull ... 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

      Set<byte @NonNull []> sUnion(byte @NonNull [] @NonNull ... 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

      Long sUnionStore(byte @NonNull [] destKey, byte @NonNull [] @NonNull ... 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

      Set<byte @NonNull []> sMembers(byte @NonNull [] 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

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

      List<byte @NonNull []> sRandMember(byte @NonNull [] 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 @NonNull []> sScan(byte @NonNull [] 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: