'zpopmax'可以和redis-py-cluster一起使用吗?

Can 'zpopmax' be used with redis-py-cluster?

我正在尝试将 zpopmax 与 python rediscluster (repo) 中的排序集一起使用,但下面的非常简单的程序因 AttributeError 而失败.

问题:如何用rediscluster实现zpopmax? 如果真的没有实现,我只好在一个事务中同时使用zrevrangezrem来保证线程安全

可能有用的背景

我注意到该命令在常规(非集群)中可用redis-py. I also see the command tested in the git repo所以我可能遗漏了一些简单的东西。

我也尝试 zpopmax 使用常规 redis 并得到同样的错误。

我的reids-py-cluster is v1.3.6. My redis-py is v2.10.6. My actual Redis是v5.0.4

代码

    from rediscluster import StrictRedisCluster as s

    rc = s(startup_nodes=[{'host': 'localhost', 'port': '7000'}],
           decode_responses=True)
    rc.zadd('my-set-name', 3, 'my-key-name')

    # print to confirm zadd worked
    print(rc.zrange('my-set-name', 0, -1, withscores=True)) 

    # expecting this to print 'my-key-name'
    print(rc.zpopmax('my-set-name')) # Attribute Error

我希望最后一个打印语句的输出类似于“my-key-name”,但我收到了一个 AttributeError

感谢您的帮助:)

问题似乎是 redis-py 添加了 support for ZPOPMAX in version 3.0, but redis-py-cluster 1.3.6 requires 旧版本的 redis-py。

这里最简单的解决方案可能就是等待 redis-py-cluster 更新。此固定引起的问题已 acknowledged, and the next version will add support for redis-py 3.0.

版本!正如凯文的回答中所述,版本是这里的问题。但是,我 可以 实际上使用此设置进行操作:

代码

from rediscluster import RedisCluster as s

rc = s(startup_nodes=[{'host': 'localhost', 'port': '7000'}],
       decode_responses=True)
rc.zadd('my-set-name', {'my-key-name':3})

print(rc.zpopmax('my-set-name')) # WORKS! (prints [('my-key-name', 3.0)])

感谢 Kevin Christopher Henry 的帮助。