Home > Backend Development > PHP Tutorial > PHP MemCached advanced cache configuration graphic tutorial

PHP MemCached advanced cache configuration graphic tutorial

高洛峰
Release: 2023-03-04 14:00:02
Original
1423 people have browsed it

1. Introduction to Memcache

memcache is a high-performance distributed memory object cache system. It can be used to store data in various formats, including images, videos, files, and database retrieval results. wait.
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高级缓存配置图文教程

#step2 Install memcache into the windows service: c:\mem\memcached.exe -d install. If there is no error message, the installation is complete.
step3 Start the memcache service: c:\mem\memcached.exe -d start. If there is no error message, the startup is successful. As shown in the figure below:

PHP MemCached高级缓存配置图文教程

Note: If you do not need to add memcache to the windows service, you can manually double-click the decompression and start memcached.exe in the root directory each time. Then step2 and step3 are not needed. 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高级缓存配置图文教程

PHP MemCached高级缓存配置图文教程

PHP MemCached高级缓存配置图文教程

#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: php\ext\

Step2 Add extension=php_memcache to PHP.ini .dll, just restart Apache.

(2) Test whether the configuration is successful

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

PHP MemCached高级缓存配置图文教程

(3) Testing memcache in PHP

<?php 
$mem = new Memcache; 
$mem->connect(&#39;127.0.0.1&#39;,11211) or die("连接失败"); 
$mem->getVersion(); 
?>
Copy after login

For more PHP MemCached advanced cache configuration graphic tutorials and related articles, please pay attention to PHP Chinese net!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template