w3resource

Redis Sorted Sets: ZLEXCOUNT

ZLEXCOUNT key min max

Redis ZLEXCOUNT command is used to return the number of elements in the sorted set at the key with a value between minimum and maximum when all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering.

  • min, max are the range of the member. To view all the -, + use.
  • min, if you give the max value must be used '[' or '(' in the front. 
  • '[' Is used to contain a value, and '(' is used to block out. 

Syntax:

ZLEXCOUNT KEY MIN MAX

Available since

2.8.9.

Return Value

Integer replies the number of elements in the specified score range.

Return Value Type

Integer

Example: Redis ZLEXCOUNT

127.0.0.1:6379> ZADD mycityset 1 Delhi 1 Mumbai 1 London 1 Paris 1 Tokyo
(integer) 5
127.0.0.1:6379> ZRANGEBYLEX mycityset - +
1) "Delhi"
2) "London"
3) "Mumbai"
4) "Paris"
5) "Tokyo"
127.0.0.1:6379> ZLEXCOUNT mycityset "[London" +
(integer) 4
127.0.0.1:6379> ZLEXCOUNT mycityset "(London" +
(integer) 3
127.0.0.1:6379> ZLEXCOUNT mycityset "(London" "(Paris"
(integer) 1
127.0.0.1:6379> ZLEXCOUNT mycityset "[London" "(Paris"
(integer) 2

Previous: ZINTERSTORE
Next: ZRANGE



Follow us on Facebook and Twitter for latest update.