参考地址:

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})

相关文章:

  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2021-05-26
  • 2021-08-21
  • 2022-12-23
  • 2021-08-29
猜你喜欢
  • 2021-08-28
  • 2021-12-03
  • 2021-10-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
相关资源
相似解决方案