Created
July 4, 2012 10:17
-
-
Save gerhard/3046550 to your computer and use it in GitHub Desktop.
redis zrevrange different results. Running v2.4.8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redis 127.0.0.1:6379> zrevrange foo 0 -1 | |
1) "1570995626" | |
redis 127.0.0.1:6379> zrevrange foo 0 -1 WITHSCORES | |
1) "1570995626" | |
2) "1341396994" | |
# Why am I getting different results? |
Right, but shouldn't there be 2 members in both cases?
No, because in the second command, the 2) entry is the score, because you ran it with WITHSCORES. In the first command, it only returned the member, because there was no WITHSCORES
OK, got it:
redis> ZREVRANGE myzset 0 -1
1) "three"
2) "two"
3) "one"
redis> ZREVRANGE myzset 0 -1 WITHSCORES
1) "three"
2) "3"
3) "two"
4) "2"
5) "one"
6) "1"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
zrevrange WITHSCORES prints the member's score after the key in the response. Without WITHSCORES, only the member is printed.