Home  >  Article  >  Backend Development  >  Introduction to the installation and working principle of PHP memory caching technology memcached_PHP tutorial

Introduction to the installation and working principle of PHP memory caching technology memcached_PHP tutorial

WBOY
WBOYOriginal
2016-07-15 13:29:36811browse

What we are going to tell you today is about 1. Introduction to PHP memory caching technology memcached

On many occasions, we will hear the name memcached. But many students have only heard of it and have not used it or actually understood it. They only know that it is a very good thing. Here is a brief introduction: memcached is an efficient and fast distributed memory object caching system, mainly used to accelerate WEB dynamic applications.

2. PHP memory caching technology memcached installation

First, download memcached. The latest version is 1.1.12. You can download memcached-1.1.12.tar directly from the official website. gz. In addition, memcached uses libevent, and I downloaded libevent-1.1a.tar.gz.

The next step is to unpack, compile and install libevent-1.1a.tar.gz and memcached-1.1.12.tar.gz respectively: # tar -xzf libevent-1.1a.tar.gz

# cd libevent-1.1a

# ./configure –prefix=/usr

# make

# make install

# cd ..

# tar -xzf memcached-1.1.12.tar. gz

# cd memcached-1.1.12

# ./configure –prefix=/usr

# make

# make install

After the installation is complete, memcached should be in /usr/ bin/memcached.

3. Run the PHP memory caching technology memcached daemon

Running the memcached daemon is very simple, just a command line, no need to modify any configuration files (there is no configuration file for you Modification):

/usr/bin/memcached -d -m 128 -l 192.168.1.1 -p 11211 -u httpd

Parameter explanation:

-d runs memcached in daemon mode;

-m sets the memory size that can be used by PHP memory caching technology memcached, in M;

-l sets the monitoring IP address. If it is the local machine, this parameter usually does not need to be set;

-p sets The listening port defaults to 11211, so this parameter does not need to be set;

-u specifies the user. If you are currently root, you need to use this parameter to specify the user.

Of course, there are other parameters that can be used. You can see them by running man memcached.

4. The working principle of PHP memory caching technology memcached

First of all, memcached runs in one or more servers as a daemon, accepting client connection operations at any time. It can be written in various languages. Currently known client APIs include Perl/PHP/Python/Ruby/Java/C#/C and so on. After clients such as PHP establish a connection with the memcached service, the next thing is to access objects. Each accessed object has a unique identifier key. Access operations are performed through this key and saved to memcached. The objects in are actually placed in memory, not stored in cache files. This is why PHP memory caching technology memcached can be so efficient and fast. Note that these objects are not persistent, and the data inside will be lost after the service is stopped.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446354.htmlTechArticleWhat we are going to tell you today is about 1. Introduction to PHP memory caching technology memcached. On many occasions, we will listen to the name memcached, but many students have only heard of it and...
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