Saturday 11 April 2015

INCR key : Increment value stored at key by one


Syntax
INCR key
    Increments the value of key by one.

Returns
Returns the value of key after the increment.
127.0.0.1:6379> set var 10 
OK 
127.0.0.1:6379> incr var 
(integer) 11 
127.0.0.1:6379> get var 
"11" 
 
"INCR" operation is limited to 64 bit signed integers, so if you try to perform on more than 64-bit numbers, it throws "out of range" error.

127.0.0.1:6379> set var 123456789098765432123456789 
OK 
127.0.0.1:6379> incr var 
(error) ERR value is not an integer or out of range 
 
INCR” operaion performs on strings that can convert to integers, else error thrown.

127.0.0.1:6379> set var "hari" 
OK 
127.0.0.1:6379> incr var 
(error) ERR value is not an integer or out of range 
127.0.0.1:6379> 

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment