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

标签 python redis redis-cluster

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

问题:如何使用rediscluster实现zpopmax? 如果真的没有实现,我将不得不在事务中同时使用zrevrangezrem来确保线程安全。

可能有用的背景

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

我还尝试了使用常规 rediszpopmax 并得到了同样的错误。

我的 reids-py-cluster是 v1.3.6。我的redis-py是 v2.10.6。我的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在 3.0 版中,但 redis-py-cluster 1.3.6 requires旧版本的 redis-py。

这里最简单的解决方案可能只是等待 redis-py-cluster 更新。此固定引起的问题已acknowledged ,下一个版本将 add support对于 redis-py 3.0。

关于python - 'zpopmax' 可以与 redis-py-cluster 一起使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57730517/

相关文章:

python - 如何为我的数据创建三个新列?

python - 从 slack url 下载加密/压缩的 7z 文件

python ,SQLAlchemy : Create bounding circle for GPS Coordinates?

python - Django 用户模型用户名 (unique=False)

events - EXPIRE 键 0 未通知 Redis 订阅者

redis - 有没有办法使用内置的 Apache Beam Redis I/O 转换来执行 Redis GET 命令?

ruby-on-rails - Ruby on Rails 总是指向本地的 redis 服务器

redis - Golang Redis 哨兵客户端

redis - 单分片 Redis Cluster 怎么会出现 CROSSLOT 错误?

Redis读写并发