PHP extension-memcache

Source: Internet
Author: User
Tags zts

MemcacheWhat is it?

Memcache is a free and openSource code, High-performance, allocated memory object cache system. Used to accelerate Dynamic Web ApplicationsProgramTo reduce the database load. It can cope with any number of connections and use non-blocking network I/O. Because its working mechanism is to open up a space in the memory, and then create a hashtable, memcached self-manages these hashtable. MemcachedWhat is it? Memcached is the main program file of the memcache system. It runs on one or more servers in the form of a daemon. It accepts connection operations from the client at any time and uses shared memory to access data. PHPWhat is memcache in? Memcache mentioned in PHP is an extension of PHP and a client used to connect to memcached. Download files Wget

Http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz

Wget http://www.monkey.org /~ Provos/libevent-1.4.13-stable.tar.gz
Wget http://pecl.php.net/get/memcache-2.2.5.tgz
1. InstallationLibevent Install the libevent library before installing memcached, because memcached uses libevent for socket processing. Tar zxvf libevent-2.0.10-stable.tar.gz
CD libevent-2.0.10-stable
./Configure
Make
Make install
2. Install memcached Tar zxvf memcached-1.4.5.tar.gz
CD memcached-1.4.5
./Configure -- With-libevent =/usr/local
Make
Make install
CD ..
Memcached-D-M 10-u root-l 202.207.177.177-P 11211-C 256-P/tmp/memcached. PID parameter description: The-D option is to start a daemon process,
-M indicates the amount of memory allocated to memcache. The unit is mb. Here I am 10 MB,
-U is the user who runs memcache. Here I am root,
-L is the IP address of the listener server. If there are multiple IP addresses, I have specified the Server IP address 202.207.177.177,
-P is the port for memcache listening. I have set port 11211 here, preferably port 1024 or above,
-The "C" option is the maximum number of concurrent connections. The default value is 1024. I have set 256 here, which is based on the load of your server,
-P is the PID file for saving memcache, Which is saved in/tmp/memcached. PID, 2. to end the memcache process, run kill 'cat/tmp/memcached. PID can also start multiple daemon processes, but the ports cannot be repeated. 3. Check whether memcached starts netstat-ant.
TCP 0 0 202.207.177.177: 11211 0.0.0.0: * port listparts 11 has been enabled, indicating that memcached has been started properly. 3. Install memcache Tar zxvf memcache-2.2.6.tgz
CD memcache-2.2.6
/Data/PHP/bin/phpize
./Configure -- enable-memcache -- With-PHP-Config =/data/PHP/bin/PHP-config -- With-zlib-Dir
Make
Make install The default module generation path is/data/PHP/lib/PHP/extensions/no-debug-non-zts-20090626/  Modify the PHP configuration file PHP. ini and add the following content: Vim/data/PHP/etc/PHP. ini Extension_dir = "/data/PHP/lib/PHP/extensions/no-debug-non-zts-20090626 /"
Extension = memcache. So   4. Test Run the following PHP file. If this is a test! Is output !,
<? PHP
$ Mem = new memcache;
$ Mem-> connect ("192.168.25.237", 11211 );
$ Mem-> set ('key', 'This is a test! ', 0, 60 );
$ Val = $ mem-> get ('key ');
Echo $ val;
?>

[Root @ localhost ~] #/Data/PHP/bin/PHP/data/nginx/html/test. php
This is a test!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.