In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what the role of memcached expansion in php is, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
The difference between memcache and memcached
Before writing this article, I have been vague about memcache and memcached, with a difference of one letter. I would like to sum up:
What is Memcache?
Memcache is a free and open source, high performance, allocated memory object caching system. Used to accelerate dynamic web applications and lighten database load. It can handle any number of connections, using a non-blocking network IO. Because it works by opening up a piece of space in memory and then creating a Hash table, Memcached manages these Hash tables itself.
Memcached is simple and powerful. Its simple design facilitates rapid deployment, is easy to develop, and solves many large data caches. Its API is available for the most popular languages.
Memcache official website: http://memcached.org/
What is Memcached?
Memcache is the project name of the system, and Memcached is the main program file of the system (the letter d can be understood as daemon). It runs in one or more servers as a daemon, accepts connection operations from clients at any time, and uses shared memory to access data.
Memcache client (php)
PHP has two memcache clients: php memcache and php memcached.
Php memcache is independently implemented in php and is an old client. From our practice, we have found that there are many problems, with few functions and fewer properties that can be set.
Http://pecl.php.net/package/memcache
Php memcached is an extension of libmemcached based on native c, which is more complete and is recommended to be replaced with php memcached.
Http://pecl.php.net/package/memcached
Memcached installation (server side) cd / root/lnmp/src/wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gztar xzf memcached-1.4.15.tar.gzcd memcached-1.4.15./configure-- prefix=/usr/local/memcachedmake & & make installln-s / usr/local/memcached/bin/memcached / usr/bin/memcached/bin/cp scripts/memcached.sysv / etc/init.d/memcachedsed-I @ ^ user =. * @ USER=root @'/ etc/init.d/memcachedsed-I / etc/init.d/memcachedsed-I's @ ^ prog =. * @ prog= "/ usr/local/memcached/bin/memcached" @'/ etc/init.d/memcached # is preceded by a soft link You can omit chmod + x / etc/init.d/memcachedchkconfig-- add memcachedchkconfig memcached oncd..
Start memcached:
Service memcached start # or execute the following memcached-p 11211-l 127.0.0.1-d-u root-P / var/run/memcached.pid-m 64m-c 1024
Explanation of several parameters:
-p TCP port on which memcached listens
-l listen to the ip address. 127.0.0.1 is local. Of course, you can also write your server IP, such as 10.0.0.10. This is the IP address of my server. If you need multiple servers to be able to read the cached data of this memcached, you must set this ip.
-d runs in daemon mode, putting the program in the background
-u memcached operating user, I set it to nobody
-pid file path of P memcached
-maximum amount of memory that can be used by m memcached
-c the maximum number of connections that memcached can accept at the same time
If you want to access memcached in socket mode, you must remove the-l and-p parameters and add the-s parameter at startup:
-socket file path of s memcached
Installation of memcache extension components in php:
Tar xzf memcache-2.2.7.tgzcd memcache-2.2.7/usr/local/php/bin/phpize./configure-with-php-config=/usr/local/php/bin/php-configmake & & make installcd.. /
In my environment, the compiled memcache.so is automatically generated in the / usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/ directory. If your environment is different, you have to modify your php.ini according to your own situation.
The next thing to do is to have php load the extension, edit your php.ini, and add the following line at the appropriate location (usually the last, or a separate ini file):
Extension=memcached.so
Then restart php or apache and run a phpinfo () to confirm that normally you should see this: memcache
Examples of simple use of php-memcache:
On what the role of memcached extension in php is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.