V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
kayseen
V2EX  ›  Python

redis 中设置不同的 score 排序问题

  •  
  •   kayseen · 2019-08-23 16:37:31 +08:00 · 1970 次点击
    这是一个创建于 1680 天前的主题,其中的信息可能已经有所发展或是发生改变。

    使用 redis 的 zset

    比如我在 key 中操作 3 个学生: student1 和 student2 和 student3 需要对他们先通过性别,在通过出生日期排序 然后设置权重

    zadd key score 性别 score 出生日期 student1 zadd key score 性别 score 出生日期 student2 zadd key score 性别 score 出生日期 student3

    请问 redis 中的 zset 可以吗?

    我在 Python 中设置两个 score 好像是无效的,不知道是不是我的方法不对

    3 条回复    2019-08-23 22:28:14 +08:00
    haloha
        1
    haloha  
       2019-08-23 18:01:38 +08:00
    redis 的 sorted set 每个 member 就只能设置一个 score...
    goodSleep
        2
    goodSleep  
       2019-08-23 19:31:03 +08:00 via Android
    试试性别和出生日期组合成一个数字?
    xiaobanlong
        3
    xiaobanlong  
       2019-08-23 22:28:14 +08:00
    楼上正解 类似基因融合的思路, 遇到正序+倒序的可以用负数或者 1-小数
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2798 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 11:50 · PVG 19:50 · LAX 04:50 · JFK 07:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.