Saturday, 11 April 2015

DECR : Decrement the value of key by one


Syntax
DECR key

Returns
Returns the value of key after the decrement.
127.0.0.1:6379> set var 10 
OK 
127.0.0.1:6379> decr var 
(integer) 9 
127.0.0.1:6379> get var 
"9"


"DECR" 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 12345678909876543212345789 
OK 
127.0.0.1:6379> decr var 
(error) ERR value is not an integer or out of range 


DECR” 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> decr var 
(error) ERR value is not an integer or out of range 

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment