python 在redis插入zset数据

python

参考地址:

https://stackoverflow.com/questions/53553009/not-able-to-insert-data-using-zaddsorted-set-in-redis-using-python

The newer version of redis from (redis-py 3.0), the method signature has changed. Along with ZADD, MSET and MSETNX signatures were also changed.

The old signature was:

data = "hello world"

score = 1

redis.zadd("redis_key_name", data, score) # not used in redis-py > 3.0

The new signature is:

data = "hello world"

score = 1

redis.zadd("redis_key_name", {data: score})

To add multiple at once:

data1 = "foo"

score1 = 10

data2 = "bar"

score2 = 20

redis.zadd("redis_key_name", {data1: score1, data2: score2})

以上是 python 在redis插入zset数据 的全部内容, 来源链接: utcz.com/z/389177.html

回到顶部