assert redis.hsetnx("myhash", "field1", "Hello") == True
assert redis.hsetnx("myhash", "field1", "World") == False

Arguments

key
str
required

The key of the hash.

field
str
required

The name of the field.

value
Any
required

The value to set.

Response

True if the field was set, False if it already existed.