Analysis of the difference between php modules memcache and memcached_PHP tutorial

WBOY
Release: 2016-07-21 15:27:53
Original
1174 people have browsed it

1. Currently, most PHP environments use the memcache version without d. This version was released earlier and is a native version developed entirely within the PHP framework. The corresponding memcached with d is based on libmemcached, so relatively speaking, the memcached version has more complete functions.
memcache:http://cn2.php.net/manual/en/book.memcache.php
memcached:http://cn2.php.net/manual/en/book.memcached.php
2.Memcache is implemented natively and supports the coexistence of OO and non-OO interfaces. Memcached uses libmemcached and only supports OO interface.
3. Another very commendable thing about memcached is that the flag is not set during operation, but has a unified setOption(). Memcached implements more of the memcached protocol.
4.memcached supports Binary Protocol, but memcache does not. This means memcached will have higher performance. However, memcached does not currently support long connections.

There is a table below to compare the php client extension memcache and memcached
http://code.google.com/p/memcached/wiki/PHPClientComparison

Another point is that everyone What is more concerning is the algorithm used. Everyone knows that the "consistent hash algorithm" is an algorithm that has less impact on the data stored on memcached when storage nodes are added or deleted. Then this algorithm can be used in both extension libraries of PHP, but the setting method is different.
Memcache
Modify php.ini and 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);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323695.htmlTechArticle1. Currently, most PHP environments use the memcache version without d. This version compares Early, it is a native version, completely developed within the PHP framework. The corresponding m with d...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!