HSETNX

Sets a hash field only if that field does not exist.

Hashes · Example verified

Syntax covered here

HSETNX key field value

The case adds a new field to a hash that already contains another field.

Tested example & replies

Requests below run in order against an empty database. Each connection authenticates with the fixture password first. Quoted values are strings; null is a nil reply; arrays preserve RESP order.

# connection: default
> HSET user name Ada
1
# connection: default
> HSETNX user city Paris
1