HSETNX

Since 1.1.0Hashes

Syntax

HSETNX key field value
  • Flags: fast, write
  • ACL categories: @fast, @hash, @write
  • Arity: 4

Sets field in the hash at key only if the field does not exist.

Reply

  • 1 if the field was set.
  • 0 if it existed; nothing changes.

Examples

> HSET u name Ada
(integer) 1
> HSETNX u name x
(integer) 0
> HSETNX u age 36
(integer) 1