w3resource

Redis Sorted Sets: ZREM

ZREM key member [member ...]

Redis ZREM command is used to remove the specified members from the sorted set stored at key. The number which does not exist are ignored and an error is returned when key exists and does not hold a sorted set.

Syntax:

ZREM key member [member ...]

Available since

1.2.0.

Return Value

Integer, the number of members removed from the sorted set, not including non-existing members.

Return Value Type

Integer

Example: Redis ZREM

127.0.0.1:6379> ZADD mysales 1556 Samsung 2000 Nokia 1800 Micromax
(integer) 3
127.0.0.1:6379> ZADD mysales 2200 Sunsui 1800 MicroSoft 2500 LG
(integer) 3
127.0.0.1:6379> ZREVRANGE mysales 0 -1 WITHSCORES
 1) "LG"
 2) "2500"
 3) "Sunsui"
 4) "2200"
 5) "Nokia"
 6) "2000"
 7) "Micromax"
 8) "1800"
 9) "MicroSoft"
10) "1800"
11) "Samsung"
12) "1556"
127.0.0.1:6379> ZREM mysales Micromax LG Nokia
(integer) 3
127.0.0.1:6379> ZREVRANGE mysales 0 -1 WITHSCORES
1) "Sunsui"
2) "2200"
3) "MicroSoft"
4) "1800"
5) "Samsung"
6) "1556"

Previous: ZRANK
Next: ZREMRANGEBYLEX



Follow us on Facebook and Twitter for latest update.