Home  >  Article  >  Backend Development  >  PHP MemCached advanced cache configuration graphic tutorial_PHP tutorial

PHP MemCached advanced cache configuration graphic tutorial_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:34:47636browse

1. Introduction to Memcache

Memcache is a high-performance distributed memory object cache system that can be used to store data in various formats, including images, videos, files and databases Search results, etc.
Websites that use Memcache generally have relatively large traffic. In order to relieve the pressure on the database, Memcache is used as a cache area to save part of the information in the memory, so that it can be accessed quickly on the front end.

2. Memcache Win32 installation
(1) Download address:
http://www.jehiah.cz/projects/memcached-win32/
( 2) Installation steps:
step1 Unzip the compressed package to any directory, such as c:mem. The directory structure is as follows:
PHP MemCached advanced cache configuration graphic tutorial_PHP tutorial
step2 Install memcache into the windows service: c:memmemcached.exe -d install. If there is no error message, the installation is complete.
step3 Start the memcache service: c:memmemcached.exe -d start. If there is no error message, the startup is successful. As shown in the figure below:
PHP MemCached advanced cache configuration graphic tutorial_PHP tutorial
Note: If you do not need to add memcache to the windows service, but manually double-click to start memcached.exe in the root directory after decompression each time, you do not need step2 and step3. . The above step2 and step3 need to be operated from 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, use the stats command to view the basic information of memcache. The details are shown in the figure below:
PHP MemCached advanced cache configuration graphic tutorial_PHP tutorial

PHP MemCached advanced cache configuration graphic tutorial_PHP tutorial

PHP MemCached advanced cache configuration graphic tutorial_PHP tutorial

3.Memcache configuration in PHP

(1) Configuration steps

step1 Download the php_memcache.dll component and place it in the php extension component directory, such as: phpext
step2 After adding extension=php_memcache.dll to PHP.ini, restart Apache will do.

(2) Test whether the configuration is successful

  Use phpinfo() to check whether it is successfully enabled. As shown in the picture below:

PHP MemCached advanced cache configuration graphic tutorial_PHP tutorial

(3) Test memcache in PHP

Copy code The code is as follows:

$ mem = new Memcache;
$mem->connect('127.0.0.1',11211) or die("Connection failed");
$mem->getVersion();
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322359.htmlTechArticle1. Memcache related introduction memcache is a high-performance distributed memory object cache system, which can be used to store Data in various formats, including images, videos, files, and database searches...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn