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...