Skip to content

zrange and zrevrange gives the same result

req.redis.zrange(from: "my_key", fromIndex: 0)

vs

req.redis.zrevrange(from: "my_key", fromIndex: 0)

One should give ascending order, and the other should give descending order right? But in my case, i am getting the same order for both.

when i do the command on redis console, i get the correct response

ZREVRANGE my_key 0 -1
1) "1E4FD2C5-C32E-4E3F-91B3-45478BCF0189"
2) "1E4FD2C5-C32E-4E3F-91B3-45478BCF0188"
3) "1E4FD2C5-C32E-4E3F-91B3-45478BCF0187"
4) "1E4FD2C5-C32E-4E3F-91B3-45478BCF0186"
5) "1E4FD2C5-C32E-4E3F-91B3-45478BCF0185"

ZRANGE my_key 0 -1
1) "1E4FD2C5-C32E-4E3F-91B3-45478BCF0185"
2) "1E4FD2C5-C32E-4E3F-91B3-45478BCF0186"
3) "1E4FD2C5-C32E-4E3F-91B3-45478BCF0187"
4) "1E4FD2C5-C32E-4E3F-91B3-45478BCF0188"
5) "1E4FD2C5-C32E-4E3F-91B3-45478BCF0189"

i ended up sending the command manually for it to work req.redis.send(command: "ZREVRANGE", with: ["my_key".convertedToRESPValue()])

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information