Php and memcached are already common issues. But there are some details that are not clear to everyone. For example, what is the difference between memcache and memcached in php. The following is a brief introduction. 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.
M
emcached php module
The following table compares the extensions of memcache and memcached on the php client.
Http://code.google.com/p/memcached/wiki/PHPClientComparison
P
hp memcached module
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 );