Saturday 18 April 2015

HSETNX key field value

Syntax
HSETNX key field value
     Sets the value to the field, if field doesn't exist. If key does not exist, a new key holding a hash is created.

Returns
1 if the field is created. 0 if the field already exists.

127.0.0.1:6379> hgetall marks 
1) "Krishna" 
2) "100" 
3) "Arjun" 
4) "99.5" 
5) "Gopi" 
6) "87" 
127.0.0.1:6379> hsetnx marks Gopi 89 
(integer) 0 
127.0.0.1:6379> hsetnx marks Rama 89 
(integer) 1 
127.0.0.1:6379> hgetall marks 
1) "Krishna" 
2) "100" 
3) "Arjun" 
4) "99.5" 
5) "Gopi" 
6) "87" 
7) "Rama" 
8) "89" 
127.0.0.1:6379> 

 
Prevoius                                                 Next                                                 Home

No comments:

Post a Comment