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;