Daily note: build Memcached + php Cache system _ PHP Tutorial

Source: Internet
Author: User
Daily note: Build a Memcached + php Cache system. Server environment, Centos6.51. install Memcached server Yum-yinstallmemcached2. configure Memcached server users and auto-start services to configure services to self-start chkconfig -- l Server environment, Centos6.5

1. install the Memcached server

Yum -y install memcached

2. configure Memcached server users and automatically start services.

Configure the service to self-start chkconfig -- level 2345 memcached on

3. configuration file

Vi/etc/sysconfig/memcachedPORT = "11211" port USER = "root" USER name MAXCONN = "1024" maximum number of connections simultaneously CACHESIZE = "64" memory size used OPTIONS =" "Additional parameters

Client environment, WindowsXp + php5.3.13 + Apache

1. remember that this php version is very important, because the php_memcache.dll extensions downloaded in many cases are not correct, and the service cannot be started normally, and the extensions are naturally unavailable.

2. the extension file corresponding to Php5.3.13, which contains the 5.2, 5.3, and 5.4 memcache extension packages. use the 5.3 extension package.

:Http://www.tanbo.name/wp-content/uploads/2012/12/php_memcache.dll_.zip

3. put the extension dll file in the ext directory under the php directory, and then put"Extension = php_memcache.dll", Add to the last row

4. restart the service, and then phpinfo (). If you find the memcache extension, it will be OK!

5. code frustrated, simple:

 Connect ('2017. 168.1.9 ', 11211); // connection $ key = 'name'; // set key $ val = 'php'; // set value $ obj-> set ($ key, $ val); // set the value (if yes, modify it. if no value exists, create and assign a value) $ obj-> add ($ key, $ val); // set the value (if no value exists, $ obj-> get ($ key); // obtain the value // $ obj-> delete ($ key ); // delete the value var_dump ($ obj-> getServerStatus ('2017. 168.1.9 ', 11211); // listens to the memcached server status var_dump ($ obj-> getStats (); // gets the server information $ obj-> close (); // Close?>

Version is the most difficult step :;

Secrets 1. install Memcached server Yum-y install memcached 2. configure Memcached server users and automatically start services to configure services as self-starting chkconfig -- l...

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.