The difference between memcache extension and memcached extension in PHP

Source: Internet
Author: User
Tags crc32 php framework

1. Most PHP environments currently use memcache versions with no D, this version is earlier and is a native version, developed entirely within the PHP framework. The corresponding memcached with D is built on the basis of libmemcached, so the memcached version is relatively functional.

memcache:http://cn2.php.net/manual/en/book.memcache.php
memcached:http://cn2.php.net/manual/en/book.memcached.php
2.Memcache is a native implementation, supporting OO and non-oo two sets of interfaces coexist. The memcached is using libmemcached, which only supports OO interfaces.
The 3.memcached also has a very good place, that is, flag is not set at the time of operation, but with a unified setoption (). The memcached implements more memcached protocols.
The 4.memcached supports binary Protocol, while Memcache is not supported. This means that the memcached will have higher performance. However, Memcached currently does not support long connections.

Here is a table to compare PHP client extensions memcache and memcached
Http://code.google.com/p/memcached/wiki/PHPClientComparison

Another point is that people are more concerned about, that is, the algorithm used. As we all know, "consistent hash algorithm" is an algorithm that has less impact on data stored on memcached when a storage node is added or deleted. The algorithm can be used in PHP's two extension libraries, except that the Setup method is different.
Memcache
Modify PHP.ini Add:
[Memcache]
Memcache.allow_failover = 1
......
......
Memcache.hash_strategy =consistent
Memcache.hash_function =CRC32
......
......
Or use the Ini_set method in PHP:
Ini_set (' memcache.hash_strategy ', ' standard ');
Ini_set (' memcache.hash_function ', ' crc32 ');

Memcached
$mem = new memcached ();
$mem->setoption (memcached::opt_distribution,memcached::D istribution_consistent);
$mem->setoption (memcached::opt_libketama_compatible,true);

Reprinted from: http://www.jb51.net/article/27366.htm

The difference between memcache extension and memcached extension in PHP

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.