Memcached Increment and Decrement Operations with Python Example – POFTUT

Memcached Increment and Decrement Operations with Python Example

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  is the operation
  • key is the key we want to increment
  • incrementvalue the value we want to increment

Example

Let’s do simple example

Now we have a key named counter we want to increment it.

Decrement

  • decr  is the operation
  • key is the key we want to increment
  • decrementvalue the value we want to increment

Example

  • decr is the operation
  • counter is the key we want to decrement
  • is how much we want to decrement
  • 122 is the result after decrements

LEARN MORE  How To Generate Random Numbers In Linux?

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)