YouTip LogoYouTip

Sorted Sets Zremrangebyrank

Redis Zremrangebyrank Command

Redis Zremrangebyrank Command

--

Redis Tutorial

Redis Tutorial Redis Introduction Redis Installation Redis Configuration Redis Data Types

Redis Commands

Redis Commands Redis Keys Redis Strings Redis Hashes Redis Lists Redis Sets Redis Sorted Sets Redis HyperLogLog Redis Pub/Sub Redis Transactions Redis Scripting Redis Connection Redis Server Redis GEO Redis Stream

Redis Advanced Tutorial

Redis Backup and Recovery Redis Security Redis Performance Testing Redis Client Connection Redis Pipelining Redis Partitioning Java Using Redis PHP Using Redis Redis Zremrangebylex Command Redis Zremrangebyscore Command

Redis Zremrangebyrank Command

Image 3Redis Sorted Sets

The Redis Zremrangebyrank command is used to remove all members in an ordered set within a specified rank (rank) range.

Syntax

The basic syntax of the redis Zremrangebyrank command is as follows:

redis 127.0.0.1:6379> ZREMRANGEBYRANK key start stop

Available Versions

>= 2.0.0

Return Value

The number of removed members.

Example

redis 127.0.0.1:6379> ZADD salary 2000 jack
(integer) 1
redis 127.0.0.1:6379> ZADD salary 5000 tom
(integer) 1
redis 127.0.0.1:6379> ZADD salary 3500 peter
(integer) 1
redis 127.0.0.1:6379> ZREMRANGEBYRANK salary 0 1
# Remove members in the index 0 to 1 range
(integer) 2
redis 127.0.0.1:6379> ZRANGE salary 0 -1 WITHSCORES
# The sorted set only has one member left
1) "tom"
2) "5000"
Image 4Redis Sorted Sets Redis Zremrangebylex Command Redis Zremrangebyscore Command
← Sorted Sets ZremrangebyscoreSorted Sets Zremrangebylex β†’