Search code examples
pythonredisredis-py

Using nx option when doing zadd in redis-py (redis ver 2.8.4)


I'm using redis 2.8.4 in a python project of mine. In a particular sorted set, I want to zadd with the nx option. The nx option isn't documented in redis-py docs, and according to the docs, it only works with redis 3.0.2 or greater.

So what's an alternative pattern I can follow to simulate the nx option when doing zadd?


Solution

  • I found solution in github issue:

    redis.execute_command('ZADD', set_name, 'NX', score, key)