Search code examples
redisjedis

Behaviour of zrangebyscore with string min and max in jedis


The method signature of the function I want to know about in Jedis is as follows:

Set<String> zrangeByScore(String key,
                          String min,
                          String max,
                          int offset,
                          int count)

The Redis documentation has information about this method with double min and max but I could not find any description anywhere of how it works with String min and max, along with the offset and count.

Can I please have a description of this method?


Solution

  • The source for the Jedis library is open-source, so you can check it out from Github and look yourself. It's a pretty straightforward library to understand, so I'd recommend it.

    https://github.com/xetorthio/jedis/blob/master/src/main/java/redis/clients/jedis/Jedis.java

    If you follow the zrangeByScore method which takes double min and max the library actually converts the double arguments to Strings, before converting the String to a byte[] and sending to Redis. The method which takes String min and max converts them straight to byte[]. If you look all arguments are actually sent to Redis as byte[]

    So the String version is exactly the same as the double version (it is still expecting you to use number for min and max), it's just there as a convenience.