zrange
zrange is a command used with Redis sorted sets to retrieve members in a specified rank range. It returns elements ordered by their score in ascending order, optionally including their scores. zrange operates on a key that identifies a sorted set.
Syntax and parameters: ZRANGE key start stop [WITHSCORES]. key is the name of the sorted set. start
Behavior: If the key does not exist or the set is empty, zrange returns an empty list.
Examples: ZRANGE leaderboard 0 9 returns the first ten members by score. ZRANGE leaderboard -5 -1 WITHSCORES
Performance: The operation runs in O(log(n) + m) time, where n is the number of elements in the
Related commands: ZREVRANGE returns results in reverse order; ZRANGEBYSCORE and ZREVRANGEBYSCORE return elements within a score