Php memory cache technology

Source: Internet
Author: User
The php memory cache technology has heard the memcached name in many occasions, but I have only heard of it and I have never used it or actually understood it. I only know it is a good stuff. Memcached is an efficient and fast distributed memory object cache system, mainly used to accelerate dynamic WEB applications. Recently I learned about memcached, first of all, the php memory cache technology.

I have heard of the memcached name in many occasions, but I have only heard of it, but I have never used it or actually learned it. I only know it is a good stuff. Memcached is an efficient and fast distributed memory object cache system, mainly used to accelerate dynamic WEB applications. I recently learned about memcached.

The first step is to download memcached, which is available in both windows and linux versions. it is very easy to run the memcached daemon. you only need one command line and do not need to modify any configuration files:

/Usr/bin/memcached-d-m 128-l 192.168.1.1-p 11211-u httpd

Parameter description:

-D run memcached in daemon mode;

-M: Set the memory size that can be used by the PHP memory cache technology memcached. the unit is M;

-L set the IP address of the listener. if it is a local machine, this parameter is usually not set;

-P: Set the listening port. the default value is 11211. Therefore, you can leave this parameter unspecified;

-U indicates the user.

 Connect ('localhost', 11211) or die ("cocould not connect"); // connect to memcache $ version = $ memcache-> getVersion (); // Obtain the memcache version echo "Server's version :". $ version."
"; $ Tmp_object = 123; if ($ memcache-> get ('key') {$ memcache-> increment ('key', 2 ); $ va = $ memcache-> get ('key'); echo $ va; // variable auto-increment, the variable is stored in the memory, after modification, refresh and keep modification var_dump ($ memcache-> getStats (); exit () ;}$ memcache-> add ('key', $ tmp_object, false, 10) or die ("Failed to save data at the server"); echo "Store data in the cache (data will expire in 10 seconds)
"; $ Get_result = $ memcache-> get ('key'); echo" Data from the cache:
"; Var_dump ($ get_result); var_dump ($ memcache-> getStats ();?>

?

?

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.