Memcache is a high-performance distributed memory object cache system that can store data in various formats, including images, videos, files, and database retrieval results.
1. Introduction to Memcache
Memcache is a high-performance distributed memory object cache system that can store data in various formats, including images, videos, files, and database retrieval results.
Memcache websites generally have a large traffic volume. to relieve the pressure on the database, apsaradb for Memcache is used as a cache area and some information is stored in the memory, allowing quick access at the front end.
2. install Memcache Win32
(1 ):
Http://www.jehiah.cz/projects/memcached-win32/
(2) installation steps:
Step 1 extract the compressed package to any Directory, such as c: \ mem. The directory structure is as follows:
Step 2 install memcache in windows: c: \ mem \ memcached.exe-d install. If no error message is displayed, the installation is complete.
Step 3 start the memcache service: c: \ mem \ memcached.exe-d start. If no error message is displayed, the memcache service is successfully started. As shown in:
Note: If memcached.exe is enabled in the root directory after memcached.exe is automatically removed from the Windows service, step 2 and step 3 are not required. The preceding steps 2 and step 3 must be performed at the command prompt.
(3) test whether the installation is successful
After the memcache service is successfully started, you can use telnet 127.0.0.1 11211 to test whether the connection is successful. if the connection is successful, run the stats command to view the basic information of memcache. As shown in:
3. configure Memcache in PHP
(1) configuration steps
Step 1 download the php_memcache.dll component and place it in the php extension component directory, such as php \ ext \
Step 2 add extension = php_memcache.dll to PHP. ini and restart Apache.
(2) test whether the configuration is successful
Use phpinfo () to check whether it is enabled successfully. As shown in:
(3) test memcache in PHP
The code is as follows:
$ Mem = new Memcache;
$ Mem-> connect ('127. 0.0.1 ', 127) or die ("connection failed ");
$ Mem-> getVersion ();
?>