PHP improves response speed with memcache caching technology

Source: Internet
Author: User

    1. The PHP memcache module is an efficient daemon that provides procedural and object-oriented interfaces for memory caching, especially when designing dynamic Web programs to reduce access to the database. Memcache also provides processing for communication dialogs (Session_handler).
    2. The memcache can be used either under Linux or under Windows systems.
<?PHPHeader("Content-type:text/html;charset=utf-8");$mem=NewMemcache;$mem->connect ("127.0.0.1", 11211) or die("Could Not Connect"); //Show Version$version=$mem-getversion ();Echo"Memcached Server version:".$version." <br> "; //Save Data$mem->set (' Key1 ', ' This is first value ', 0, 60); $val=$mem->get (' Key1 '); Echo"Get Key1 Value:".$val." <br> "; //Replace Data$mem->replace (' Key1 ', ' This is replace value ', 0, 60); $val=$mem->get (' Key1 '); Echo"Get Key1 Value:".$val. "<br>"; //Save Array$arr=Array(' AAA ', ' BBB ', ' CCC ', ' DDD ')); $mem->set (' Key2 ',$arr, 0, 60); $val 2=$mem->get (' Key2 '); Echo"Get Key2 Value:"; Print_r($val 2); Echo"<br>"; //Delete Data$mem->delete (' Key1 '); $val=$mem->get (' Key1 '); Echo"Get Key1 Value:".$val. "<br>"; //Clear All data$mem-Flush(); $val 2=$mem->get (' Key2 '); Echo"Get Key2 Value:"; Print_r($val 2); Echo"<br>"; //Close Connection www.bcty365.com$mem-close ();?>

PHP improves response speed with memcache caching technology

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.