HSETNX

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Set only if the field does not already exist

The usage is hsetnx key field value.
If the same field already exists, it is not stored.

Example

Command>hsetnx user-1 email help@redisgate.com
Result>0
Command>hsetnx user-1 email2 help@redisgate.com
Result>1

View animation



Syntax

HSETNX key field value

  • Available since version 2.0.0.
  • Time complexity is O(1).
Related commands HMSET, HDEL, SET, LPUSH, SADD, ZSET
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< HEXISTS HSETNX HSCAN >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.