UK [s'rem] US [s'rem]

abbr.sleep with rapid eye movements eyes with rapid eye movements while sleeping

redis SREM command syntax

Function: Remove one or more member elements from the collection key. Non-existing member elements will be ignored.

Syntax: SREM key member [member ...]

Description: When key is not a collection type, an error is returned. Before Redis 2.4, SREM only accepted a single member value.

Available versions: >= 1.0.0

Time complexity: O(N), N is the number of given member elements .

Returns: The number of elements that were successfully removed, excluding ignored elements.

redis SREM command example

# 测试数据
redis> SMEMBERS languages
1) "c"
2) "lisp"
3) "python"
4) "ruby"
# 移除单个元素
redis> SREM languages ruby
(integer) 1
# 移除不存在元素
redis> SREM languages non-exists-language
(integer) 0
# 移除多个元素
redis> SREM languages lisp python c
(integer) 3
redis> SMEMBERS languages
(empty list or set)