I. Introduction of Memcached
1. Official website: http://www.memcached.org
2. Memcached is a free and open source, high performance, distributed memory object caching system.
Second, the role:
1. Store the data in memory and read from memory when needed.
2. The purpose of general use is to reduce the number of database accesses by caching database query results to improve the speed and scalability of dynamic Web applications.
3. Principle, if there is a cache, read the cache, if not, read the database.
Third, installation
Linux
Installation
1. Installing Libevent
Official website
http://libevent.org/
1. Unzip
TAR-ZVXF libevent-2.1.8-stable.tar.gz
2. Enter the catalogue
CD libevent-2.1.8-stable
3. Implementation
./autogen.sh
4. Configuration
./configure-prefix=/usr
5. Compiling the installation
Make && make install
2. Installing memcached
Official website
http://memcached.org
1. Unzip
TAR-ZXVF memcached-1.x.x.tar.gz
2. Enter the catalogue
CD memcached-1.x.x
3. One step to get it done
./configure && make && make test && sudo make install
Start
memcached-d-U root-p 11211
Installing PHP Extensions
1. Download
Https://github.com/websupport-sk/pecl-memcache/archive/php7.zip
2. Unzip
Unzip Pecl-memcache-php7.zip
3. Enter the catalogue
CD PECL-MEMCACHE-PHP7
4. Executive Phpize
/usr/local/php/bin/phpize
5. Configuration
./configure--with-php-config=/usr/local/php/bin/php-config
6. Compiling the installation
Make && make install
7. Modify the php.ini configuration file
Quick location of php.ini and PHP extension directories
phpinfo,loaded Configuration File
Vim/usr/local/php/etc/php.ini
Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20151012/"
Extension= "memcache.so";
8. Restart Apache
/usr/local/apache2/bin/apachectl restart
Iv. Working with PHP
1. Instantiation of New Memcache ()
2. Connect database Conncet (' localhost ', 11211)
Addserver (' Localhsot ', 11211);
3. Add (' name ', $value, memcache_compressed, 10);
Set (' Name ', $value, memcache_compressed, 10);
4. Remove delete (' name ');
Flush ();
5. Get get ();
"Memcache" Memcached