Redis Sets: SREM
Redis SREM Command
Redis SREM command is used to remove the specified members from the set stored at key. Specified members that are not a member of this set are ignored. If the key does not exist, it is treated as an empty set and this command returns 0. An error is returned when the value stored at key is not a set.
Here are some common uses and scenarios for the "SREM" command:
- Element Removal: Removes specified members from a set.
- Data Cleanup: Useful for cleaning up or removing unwanted elements from a set.
- Batch Deletion: Allows for the removal of multiple elements in a single command.
- Dynamic Updates: Helps in updating the set by removing elements as part of dynamic data management processes.
Syntax:
SREM key member1 [member2]
Available since:
1.0.0.
Return Value:
Integer reply: the number of members that were removed from the set, not including non-existing members.
Return Value Type:
Integer
Example: Redis SREM
127.0.0.1:6379> SADD mycolor "red" "green" "blue" "yellow" (integer) 4 127.0.0.1:6379> SREM mycolor "yellow" (integer) 1 127.0.0.1:6379> SMEMBERS mycolor 1) "red" 2) "green" 3) "blue" 127.0.0.1:6379> SREM mycolor "orange" (integer) 0
Previous:
Redis Sets SRANDMEMBER
Next:
Redis Sets SUNION
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics