Php5-memcached is a little faster than php5-memcache

Source: Internet
Author: User
: 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.

    Related Article

    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.