Set set common operations directives
Set is a single-valued, multi-value data structure that does not allow the same elements to exist
Sadd key value [value]
Adding elements to form the association of key and value
Note that if we enter a value with duplicate content, Redis will automatically remove the weight and add it to the collection as shown below
Smembers Key
View collection elements
SCard Key
Gets the number of elements in the collection
Srem Key value
Removing elements from a collection
Srandmember key [Count]
Get multiple values randomly from the collection, without adding a number, by default randomly fetching a number, if the set number exceeds the number of data in the collection, then all out
Spop key [Count]
Random out stack, default random stack one number
Smove Key1 Key2 value1
Assign a value in Key1 to Key2
Here we move the 12 in the MySet to the myset01
Math Set Class Difference Set
Sdiff key1 Key2 [key 3]
Inside the first element and no longer behind any of the collections.
intersection
Sinter key1 Key2 [Key3]
and set
Sunion key1 Key2 [Key3]