As we see before we have done Set CAS operation to increment counter key value. Here is a operator to increment and decrement values directly.
incr key incrementvalue
- incr is the operation
- key is the key we want to increment
- incrementvalue the value we want to increment
Example
Let’s do simple example
add counter 0 0 3 123 STORED
Now we have a key named counter we want to increment it.
incr counter 1 124
Decrement
decr key decrementvalue
- decr is the operation
- key is the key we want to increment
- decrementvalue the value we want to increment
Example
decr counter 2 122
- decr is the operation
- counter is the key we want to decrement
- 2 is how much we want to decrement
- 122 is the result after decrements