Saturday, 11 April 2015

SETNX key value

Syntax
SETNX key value
   Sets the value to key, if key not exists.

Returns
   1 if the key was set
   0 if the key was not set


127.0.0.1:6379> get a 
(nil) 
127.0.0.1:6379> setnx a 100 
(integer) 1 
127.0.0.1:6379> get a 
"100" 
127.0.0.1:6379> set b 20 
OK 
127.0.0.1:6379> setnx b 200 
(integer) 0 
127.0.0.1:6379> get b 
"20" 

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment