PHP Installation Memcache Extensions

Source: Internet
Author: User

1, first download memcached server

wget http://www.memcached.org/files/memcached-1.4.20.tar.gz

Yum-y Install Libevent

Yum-y Install Libevent-devel

./configure && make && make install

Test:

Telnet 127.0.0.1 11211

Trying 127.0.0.1 ...

Connected to 127.0.0.1.

Escape character is ' ^] '.

That's a success.



Start/End

Memcached-d-M 10-u root-l 172.25.43.71-p 11200-c 256-p/tmp/memcached.pid

The-D option is to start a daemon,

-M is the amount of memory allocated to Memcache, in megabytes, 10MB

-U is the user running memcache, this is root

-L is the server IP address of the listener, if there are multiple addresses, this specifies the IP address of the server 192.168.0.122

-P is the port that sets Memcache listening, which is set to 12000, preferably more than 1024 ports

The-c option is the maximum number of concurrent connections, the default is 1024, where 256 is set according to the load on your server

-P is a PID file that is set to save Memcache

Kill ' Cat/tmp/memcached.pid '


2. Download PHP memcache


wget http://pecl.php.net/get/memcache-2.2.7.tgz


Tar zxvf memcache-2.2.7.tgz

CD memcache-2.2.7

/usr/local/php/bin/phpize//compile with Phpize

./configure--with-php-config=/usr/local/php/bin/php-config--enable-memcache

Make && make install


Put memcache.so in php.ini extension =/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so



3. Get all the keys in the Memcache

$oMem = new Memcache;

$host = ' 172.25.43.71 ';

$port = ' 11200 ';

$oMem->connect ($host, $port);

$items = $oMem->getextendedstats (' items ');

$items = $items ["$host: $port"] [' items '];

foreach ($items as $key = = $values) {

$number = $key;

$str = $oMem->getextendedstats ("Cachedump", $number, 0);

Var_dump ($STR);

$line = $str ["$host: $port"];

if (Is_array ($line) && count ($line) >0) {

foreach ($line as $key = = $value) {

echo $key. ' = ';

Print_r ($oMem->get ($key));

echo "\ r \ n";

}

}

}


PHP Installation Memcache Extensions

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.