set is an unordered collection that can contain up to (2 to the 32nd power - 1) elements. The set is implemented through the hash table, so the complexity of adding, deleting, and searching is O(1)
sadd key member adds a string element to the set set corresponding to the key, returns 1 successfully, returns 0 if the element is also in the set, and returns an error if the set corresponding to the key does not exist
Continue to add, return 0 to indicate that the addition failed, indicating that the set collection is not allowed to add duplicate elements
smembers smembers smembers key Returns all elements of the set corresponding to key, the result is unordered
sinter key1 key2 ... keyN returns the intersection of all given keys
sinterstore dstkey key1 ....... keyN Returns the intersection of all given keys and saves the intersection to dstkey
sunion key1 key2 ...... keyN returns the union of all given keys
sunionstore dstkey key1 ...... keyN returns the union of all given keys and saves the union under dstkey
sdiff key1 key2 ...... keyN returns the difference of all given keys
sdiffstore sdiffstore sdiffstore dstkey key1 ...... keyN Returns the difference of all given keys and saves the difference to dstkey
smove srckey dstkey member Remove member from the corresponding set of srckey and add it to the corresponding set of dstkey, the whole operation is atomic
scard key returns the number of elements in the set, or 0 if the set is empty or the key does not exist
sismember key member Determines whether the member is in the set, returns 1 if it exists, and 0 means it does not exist or the key does not exist
srem key member removes the specified element from the set corresponding to the key
spop key deletes and returns a random element in the set corresponding to key
srandmember key is the same as spop, randomly selects an element in the set, but does not delete the element