Difference between memcache and memcached in the php Module

Source: Internet
Author: User
Tags crc32

1. Currently, most php environments use a memcache version that does not contain d. This version was developed earlier and is developed completely within the php framework. The corresponding memcached with d is based on libmemcached. Therefore, memcached provides more comprehensive functions.
Memcache: http://cn2.php.net/manual/en/book.memcache.php
Memcached: http://cn2.php.net/manual/en/book.memcached.php
2. Memcache is native and supports both OO and non-OO interfaces. Memcached uses libmemcached and only supports the OO interface.
3. memcached also has a lot to praise, that is, the flag is not set during the operation, but has a unified setOption (). Memcached implements more memcached protocols.
4. memcached supports Binary Protocol, but memcache does not. This means that memcached has higher performance. However, memcached does not currently support persistent connections.

The following table compares the extensions of memcache and memcached on the php client.
Http://code.google.com/p/memcached/wiki/PHPClientComparison

Another point of interest is the algorithm used. We all know that the consistent hash algorithm is an algorithm that has little impact on data stored in memcached when a storage node is added or deleted. This algorithm can be used in both extension libraries of php, but the setting method is different.
Memcache
Modify php. ini to 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: DISTRIBUTION_CONSISTENT );
$ Mem-> setOption (Memcached: OPT_LIBKETAMA_COMPATIBLE, true );

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.