Saturday 11 April 2015

DECRBY key decrement : Decrement the value stored at key by decrement

Syntax
DECRBY key decrement
Decrements the number stored at key by decrement.

Returns
Returns the value of key after the decrement.

127.0.0.1:6379> set var 100 
OK 
127.0.0.1:6379> decrby var 15 
(integer) 85 
127.0.0.1:6379> get var 
"85" 


This operation is limied 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> decrby var 15 
(error) ERR value is not an integer or out of range 


This operation 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> decrby var 15 
(error) ERR value is not an integer or out of range 

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment