: This article mainly introduced the php5-memcached faster than the php5-memcache, for PHP tutorials interested in students can refer. ??
Php5-memcached is a little faster than php5-memcache
Php5-memcached and php5-memcache are two php components for operating memcached, they are developed by different people.
The official php website lists their respective usage methods:
Http://www.php.net/manual/en/book.memcache.php (installation using: sudo apt-get install php5-memcache)
Http://www.php.net/manual/en/book.memcached.php (installation using: sudo apt-get install php5-memcached)
1. first, install apache:
Sudo apt-get update
Sudo apt-get install apache2
2. install php5:
Sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
3. install memcached:
Sudo apt-get install memcached
4. then install the php5-memcached and php5-memcache:
Sudo apt-get install php5-memcache
Sudo apt-get install php5-memcached
5. restart apache2:
Sudo service apache2 restart
6. edit test. php as follows:
addServer('localhost', 11211);$start = microtime(true);foreach ($values as $k => $v) $m->set($k, $v, 3600);$time = microtime(true)-$start;echo "memcached set: $time\n";$start = microtime(true);foreach ($values as $k => $v) $m->get($k);$time = microtime(true)-$start;echo "memcached get: $time\n";// Memcache$m = new Memcache();$m->addServer('localhost', 11211);$start = microtime(true);foreach ($values as $k => $v) $m->set($k, $v, 0, 3600);$time = microtime(true)-$start;echo "memcache set: $time\n";$start = microtime(true);foreach ($values as $k => $v) $m->get($k);$time = microtime(true)-$start;echo "memcache get: $time\n";?>
7. run http: // machinename/test. php or php/var/www/html/test. php.
Root @ machinename # php/var/www/html/test. php
Memcache vs memcached: 10000 keys
Memcached set: 0.7015380859375
Memcachedget: 0.61220598220825
Memcache set: 0.78830289840698
Memcache get: 0.74954390525818
~
Root @ machinename # php/var/www/html/test2.php
Memcache vs memcached: 10000 keys
Memcache set: 0.78771591186523
Memcache get: 0.75219798088074
Memcached set: 0.69968199729919
Memcachedget: 0.60679888725281
Reference:
1. https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu
2. https://www.digitalocean.com/community/tutorials/how-to-install-and-use-memcache-on-ubuntu-14-04
3. https://www.leaseweb.com/labs/2013/03/memcache-vs-memcached-php-benchmark/
The above introduced the php5-memcached is a little faster than the php5-memcache, including the content, hope to be interested in PHP Tutorial friends help.