V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · Aug 23, 2019 · 2651 views
    This topic created in 2452 days ago, the information mentioned may be changed or developed.

    使用 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 replies    2019-08-23 22:28:14 +08:00
    haloha
        1
    haloha  
       Aug 23, 2019
    redis 的 sorted set 每个 member 就只能设置一个 score...
    goodSleep
        2
    goodSleep  
       Aug 23, 2019 via Android
    试试性别和出生日期组合成一个数字?
    xiaobanlong
        3
    xiaobanlong  
       Aug 23, 2019
    楼上正解 类似基因融合的思路, 遇到正序+倒序的可以用负数或者 1-小数
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   875 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 21:38 · PVG 05:38 · LAX 14:38 · JFK 17:38
    ♥ Do have faith in what you're doing.