Memcached Replace Operation with Python Examples – POFTUT

Memcached Replace Operation with Python Examples

Replace operation will change existing key-value. If the key-value do not exists we will get an response like NOT_STORED. Its syntax is similar to add.

  • replace is the name of the verb
  • key the key which replaced
  • flag as flag
  • expiretime  the time range the key-value stored in memcached
  • bytes  the size of the new value
  • value new value

Let’s add new data  and check it exists.

We will replace poftut key-value with new value.

  • replace  the verb
  • poftut  is the key we want to replace its data
  • flags
  • 100 the second we want to hold new key-value
  • is the size of new value
  • testnew  is new value
  • STORED  the result of the successful replace operation

Python Application

We save the code as filename replace.py.After running the code the output we get.

LEARN MORE  Looking For Python Tutor or Training?

Leave a Reply

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

Enjoy this blog? Please spread the word :)