PHP memcache Add replace set differences and other usage collection

Source: Internet
Author: User

The difference between the add replace set

recently encountered a problem in the interview memcache the difference between the add and replace set, so this step is to add a cached data to the server, when the key already exists will return a false, otherwise return a truereplace is to replace a cached data within the server, return a false if the key does not exist, or return true set is the collection of add and replace, if the key exists in the substitution, does not exist on the set, the return is true

Increment Decrement Delete addition subtraction delete operation

Example: $memcache=NewMemcahe (); $memcache->connect ('localhost','11211'); $memcache-Set("value",3); $memcache->increment ("value",5);//Can be used as a counter, increment 5 $memcache at a time->decrement ("value",6);
$value = $memcache->get ("value"); 2
$memcache->delete ("value");
$memcahe->flush ();//Set all caches to expire and do not delete

PHP memcache Add replace set differences and other usage collection

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.