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″ portuser =" root "username maxconn=" 1024″ simultaneous maximum number of connections Cachesize= "64″ used memory size 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=NewMemcache ();//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 the value (no creation exists, there is no modification) $obj->get ($key);//Gets the value//$obj->delete ($key);//Delete value Var_dump($obj->getserverstatus (' 192.168.1.9 ', 11211));//monitor memcached Server Status Var_dump($obj->getstats ());//Get Server information $obj->close ();//Close?>
Version is the most deceptive step:;