Arguments
str
required
The key of the hash.
str
required
The name of the field.
Any
required
The value to set.
Response
True if the field was set, False if it already existed.Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
assert redis.hsetnx("myhash", "field1", "Hello") == True
assert redis.hsetnx("myhash", "field1", "World") == False
Write a field to a hash but only if the field does not exist.
True if the field was set, False if it already existed.assert redis.hsetnx("myhash", "field1", "Hello") == True
assert redis.hsetnx("myhash", "field1", "World") == False
Was this page helpful?