Hash
HSETNX
Write a field to a hash but only if the field does not exist.
Arguments
keybodystrrequired
The key of the hash.
fieldbodystrrequired
The name of the field.
valuebodyAnyrequired
The value to set.
Response
boolrequired
True if the field was set, False if it already existed.
Example
assert redis.hsetnx("myhash", "field1", "Hello") == Trueassert redis.hsetnx("myhash", "field1", "World") == False