推荐学习书目
› 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 · 3056 views
    This topic created in 2633 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
    haloha
    Aug 23, 2019
    1
    redis 的 sorted set 每个 member 就只能设置一个 score...
    goodSleep
    goodSleep
    Aug 23, 2019 via Android
    2
    试试性别和出生日期组合成一个数字?
    xiaobanlong
    xiaobanlong
    Aug 23, 2019
    3
    楼上正解 类似基因融合的思路, 遇到正序+倒序的可以用负数或者 1-小数
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1715 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 14:50 · PVG 22:50 · LAX 06:50 · JFK 09:50
    ♥ Do have faith in what you're doing.