SETS Intro

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Introduction

In Sets, a key and values have a one-to-many relationship.
Values are stored regardless of insertion order and are unique. If value A is stored twice, only one remains.
In Sets, a value is called a member because it is a set.
Sets are mainly used in games such as card games, or wherever set operations are needed.

Command summary

  • SET: SADD, SMOVE
  • GET: SMEMBERS, SCARD, SRANDMEMBER, SISMEMBER, SSCAN
  • POP: SPOP
  • REM: SREM
  • Set operations: SUNION, SINTER, SDIFF, SUNIONSTORE, SINTERSTORE, SDIFFSTORE
  • Enterprise: SLS, SRM, SLEN

Sets command list

CommandsVersionSyntaxDescription
SADD1.0.0key member [member ...]Add members to a set
SREM1.0.0key member [member ...]Remove members from a set
SMEMBERS1.0.0keyGet all members of a set
SCARD1.0.0keyGet the number of members in a set
SUNION1.0.0key [key ...]Get the union
SINTER1.0.0key [key ...]Get the intersection
SDIFF1.0.0key [key ...]Get the difference
SUNIONSTORE1.0.0dest_key src_key [src_key ...]Store the union in a new set
SINTERSTORE1.0.0dest_key src_key [src_key ...]Store the intersection in a new set
SDIFFSTORE1.0.0dest_key src_key [src_key ...]Store the difference in a new set
SISMEMBER1.0.0key memberCheck whether a member exists in a set
SMOVE1.0.0src_key dest_key memberMove a member from the source set to the destination set
SPOP1.0.0key [count]Remove and return a random member from a set
SRANDMEMBER1.0.0key [count]Get a random member from a set
SSCAN2.8.0key cursor [MATCH pattern]
[COUNT count]
Iterate members in batches
SMISMEMBER6.2.0key member [member ...]Check whether members exist in a set - multiple members
SLS Ent 6.0.0key patternGet values by pattern
SRM Ent 6.0.0key patternDelete values by pattern
SLEN Ent 7.0.0keyReturn the number of members in a key

Total : 19


Sets command overview



Redis Internal : SET internal data structure

SET data structure


PDF manual


<< BRPOPLPUSH SETS Introduction SADD >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.