command prototype |
Time complexity |
command description |
return value |
Sadd Key member [member ...] |
O (N) |
N In time complexity indicates the number of members of the operation. If the inserted procedure is used, the member in the parameter already exists in the set, the member will be ignored, and the other member will still be inserted normally. If the key does not exist before the command is executed, the command creates a new set and then inserts the members of the parameter in succession. If the value of the key is not a set type, the command returns the associated error message. |
The number of members actually inserted in this operation. |
SCard Key |
O (1) |
Gets the number of members in the set. |
Returns the number of members in the set, or 0 if the key does not exist. |
Sismember Key Member |
O (1) |
Determines whether the specified member in the parameter already exists in the set collection associated with key. |
1 means that it already exists, 0 means it does not exist, or the key itself does not exist. |
smembers Key |
O (N) |
N in the time complexity represents the number of members that already exist in the set. Gets all the members in the set associated with the key. |
Returns all the members in the set. |
SPOP Key |
O (1) |
Randomly removes and returns a member of the set. Because the layout of elements in set is not externally controlled, it is not possible to determine which element is at the head or tail of the set as the list does. |
Returns the removed member, or nil if the key does not exist. |
Srem Key member [member ...] |
O (N) |
N In time complexity indicates the number of members to be deleted. Removes the member specified in the parameter from the set associated with the key, the non-existent parameter member is ignored, and if the key does not exist, it is treated as an empty set. |
The number of members actually removed from set, or 0 if not. |
Srandmember Key |
O (1) |
Like Spop, a member of a set is returned randomly, but the command does not delete the returned member. |
Returns a member of a random position, or nil if key does not exist. |
smove Source Destination Member |
O (1) |
Atomically moves the member in the argument from the source key into the set associated with the destination key. So at some point, the member either appears in source or appears in destination. If the member does not exist in source, the command will no longer perform any action and return 0, otherwise the member will be moved from source to destination. If the member already exists in destination at this point, the command simply moves the member out of source. If the value associated with the key is not set, the associated error message is returned. |
1 indicates normal movement, and 0 indicates that the source does not contain parameter members. |
Sdiff key [key ...] |
O (N) |
N in time complexity represents the total number of members in all sets. Returns the difference between the set associated with the first key in the parameter and the members in the sets associated with all keys thereafter. If key does not exist, it is treated as an empty set. |
The collection of variance result members. |
sdiffstore destination key [key ...] |
O (N) |
The command is functionally identical to the Sdiff command, and the only difference between the two is that Sdiff returns the result member of the difference, which stores the differential member in the destination associated set. If the destination key already exists, the operation overrides its members. |
Returns the number of differential members. |
SINTER key [key ...] |
O (N*M) |
N in time complexity represents the number of elements in the minimum set, and m represents the number of sets in the parameter. The command returns the intersection of the members in the sets associated with all keys in the parameter. Therefore, if either key in the parameter is associated with a set that is empty, or if a key does not exist, the result of the command will be an empty box. |
The collection of intersection result members. |
sinterstore destination key [key ...] |
O (N*M) |
The command is functionally identical to the sinter command, and the only difference between the two is that sinter returns the result member of the intersection, and the command stores the intersection member in the destination associated set. If the destination key already exists, the operation overrides its members. |
Returns the number of intersection members. |
sunion key [key ...] |
O (N) |
N in time complexity represents the total number of members in all sets. The command returns the sets of the members in all keys associated with the key in the parameter. |
Sets the set of resultant members. |
sunionstore destination key [key ...] |
O (N) |
The command is functionally identical to the sunion command, and the only difference between the two is that the sunion returns the result member of the set, and the command stores the integrator in the destination associated set. If the destination key already exists, the operation overrides its members. |
Returns and the number of integrators. |