ZLEXCOUNT key min max
This command counts the number of members in a sorted set between a given lexicographical range.
When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns the number of elements in the sorted set at the key with a value between min and max.
RETURN VALUE:
Integer reply, the number of elements in the specified score range.
Syntax:
ZLEXCOUNT key min max
Example 1: When the min and max are valid string
redis:6379> ZADD mykey 2 A 1 C 3 B 4 E 5 D(integer) 5redis:6379> ZLEXCOUNT mykey - +(integer) 5
Output
5
Example 2: When the min and max are not a valid string
redis:6379> ZADD mykey 2 A 1 C 3 B 4 E 5 D(integer) 5redis:6379> ZLEXCOUNT mykey 1 7(error) min or max not valid string range itemredis:6379> ZLEXCOUNT mykey A Z(error) min or max not valid string range item
Output
(error) min or max not valid string range item
No comments:
Post a Comment