Php5-memcached is a little faster than php5-memcache
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 with: sudo apt-get install php5-memcache) http://www.php.net/manual/en/book.memcached.php (installation with: 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/