YouTip LogoYouTip

Sets Srem

body { font-family: 'Segoe UI', sans-serif; background-color: #f8f9fa; } .container { max-width: 1200px; margin: auto; padding: 20px; } h1, h2, h3 { color: #2c3e50; } code { background-color: #f0f0f0; border-radius: 4px; padding: 2px 6px; font-family: 'Courier New', monospace; } pre { background-color: #f0f0f0; border: 1px solid #ccc; padding: 15px; border-radius: 5px; overflow-x: auto; } .nav-link { color: #3498db; } .nav-link:hover { color: #2980b9; text-decoration: none; } footer { margin-top: 50px; text-align: center; color: #7f8c8d; font-size: 14px; }

Redis Srem Command | .com

-- Learning not just technology, but also dreams!

Redis Tutorial

Redis Commands

Advanced Redis Tutorials

Redis Srem Command

Up Redis Sets (Set)

The Redis SREM command is used to remove one or more members from a set. Members that do not exist in the set are ignored.

If the key is not of type set, an error will be returned.

In Redis versions prior to 2.4, SREM only accepted a single member value.

Syntax

The basic syntax for the Redis SREM command is as follows:

redis 127.0.0.1:6379> SREM KEY MEMBER1..MEMBERN

Available Version

>= 1.0.0

Return Value

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

Example

redis 127.0.0.1:6379> SADD myset1 "hello"
(integer) 1
redis 127.0.0.1:6379> SADD myset1 "world"
(integer) 1
redis 127.0.0.1:6379> SADD myset1 "bar"
(integer) 1
redis 127.0.0.1:6379> SREM myset1 "hello"
(integer) 1
redis 127.0.0.1:6379> SREM myset1 "foo"
(integer) 0
redis 127.0.0.1:6379> SMEMBERS myset1
1) "bar"
2) "world"
Up Redis Sets (Set)

← Sets SunionSets Srandmember β†’