Last active
December 25, 2015 06:19
-
-
Save huangzworks/6931111 to your computer and use it in GitHub Desktop.
Redis 的 SORT 命令在不给定 STORE 选项时,使用二进制方式来对比字符串(memcmp);在给定 STORE 选项时,根据本地编码来对比字符串(strcoll);所以即使对同一个键进行排序,也可能会产生两种不同的结果。
This file contains 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
>>> from redis import Redis | |
>>> r = Redis() | |
>>> r.rpush("msg", u"你好", u"早上好", u"很高兴认识你") | |
3L | |
>>> for m in r.sort("msg", alpha=True): print(m) | |
... | |
很高兴认识你 | |
你好 | |
早上好 | |
>>> r.sort("msg", alpha=True, store="sorted_msg") | |
3L | |
>>> for m in r.lrange("sorted_msg", 0, -1): print(m) | |
... | |
你好 | |
很高兴认识你 | |
早上好 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment