What's the difference between add, set, and replace in Memcache

Source: Internet
Author: User

People who have used memcache have a doubt, that is why there is a memcache in the Add method, a set method, a replace, these methods have what kind of difference, below we analyze the differences between these methods:

Memcache::add method: The Add method is used to add a data to the Memcache server to be cached.

Memcache::set method: The Set method is used to set the cached content of a specified key, and the Set method is the collection of the Add method and the Replace method

Mmecache::replace method: The Replace method replaces the cached content of a specified key and returns False if key does not exist

Comparison:

Method When key exists When key does not exist
Add False True
Replace Replace (true) False
Set Replace (true) True

I believe you know how to use these methods in the future, it is so simple

This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/tools/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.