Build memcached + PHP Cache system

Source: Internet
Author: User

Server environment, Centos6.5

1. Installing the memcached server

Yum-y Install memcached

2. Configure Memcached Server users and auto-start services, etc.

Configure the service as self-booting chkconfig--level 2345 memcached on

3. Configure the configuration file

vi/etc/sysconfig/memcachedport= "11211″ port user=" root "username maxconn=" 1024″ simultaneous maximum number of connections cachesize= "64″ Memory size used options= "" Additional parameters  

Client environment, WindowsXP + php5.3.13 + Apache

1. Remember this PHP version is very important, because many times the download of the Php_memcache.dll extension is not on, resulting in the service does not start normally, the extension is not able to use the natural

2.php5.3.13 corresponding extension file, in the package, contains the 5.2,5.3,5.4 memcache expansion pack, using 5.3 of the

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

3. Speak the extension DLL file in the PHP directory under the EXT directory, and then in PHP.ini, the " extension=php_memcache.dll ", add to the last line

4, restart the service, and then Phpinfo (), if you find the memcache extension, OK!

5. Code frustration, simple:

<?Php/*Memcached*/$obj =New Memcache ();//Instantiation of$obj->connect (' 192.168.1.9 ', 11211);//Connection$key = ' Name ';//Set key$val = ' Php ';//Set Value$obj->set ($key,$val);//Set value (existing, modify, create and assign value if not present) $obj->add ( $key, $ Val); // set value (no creation exists, cannot be modified) $ Obj->get ( $key);  get value//$obj->delete ($key);//delete value var_dump ( $obj->getserverstatus (' 192.168.1.9 ', 11211)); // listener memcached Server status  $obj->getstats ());   get server information  $obj->close ()  closed;           

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.