php module memcache and memcached distinction analysis

  • 2020-05-07 19:24:59
  • OfStack

1. Currently, most php environments use memcache version without d. This version was released earlier and is a native version, developed entirely within the php framework. The memcached with d is based on libmemcached, so the memcached version is more fully 1.
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 that supports both OO and non-OO interfaces. memcached USES libmemcached and only supports OO.
3. Another great thing about memcached is that flag is not set during operation, but has a unified setOption(). Memcached implements more memcached protocols.
4.memcached supports Binary Protocol, while memcache does not. This means that memcached will have higher performance. However, memcached does not currently support long connections.

Here is a table comparing php client extensions memcache with memcached
http://code.google.com/p/memcached/wiki/PHPClientComparison

The other point that you are concerned about is the algorithm used. It is well known that the "1-uniqueness hash algorithm" is an algorithm that has less impact on the data stored on memcached when a storage node is added or removed. The algorithm can then be used in both of php's extension libraries, but in different ways.
Memcache
modifies php.ini adds:
[Memcache]
Memcache.allow_failover = 1
...
...
Memcache.hash_strategy =consistent
Memcache.hash_function =crc32
...
...
Or use the ini_set method in php:
standard Ini_set (' memcache hash_strategy ', ' ');
crc32 Ini_set (' memcache hash_function ', ' ');

Memcached
$mem = new memcached();
$mem- > setOption(Memcached::OPT_DISTRIBUTION,Memcached::DISTRIBUTION_CONSISTENT);
$mem- > setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE,true);

Related articles: