Memcache and memcached pecl libraries on PHP

  • 2020-03-31 20:32:52
  • OfStack

As for efficiency, it is not clear by how much.

An article here also says that memcached is based on libmemcached, which is probably better.

Finally, the PHP extension based on libmemached was released in pecl.

So now you have two memcache clients on pecl. Within the framework of one is completely in the PHP development (link: http://pecl.php.net/package/memcache), one is using libmemcached (link: http://pecl.php.net/package/memcached).

These are not the most important things. One obvious advantage of using libmemcached is that as the memcached server side improves, the lib is sure to follow. Pecl ::memcache doesn't always follow up on time.

Another nice thing about pecl::memcached is that the flag is not set during operation. Instead, there is a unified setOption(). For this reason, it's worth switching from pecl::memcache to pecl::memcached. Specific interface can be seen here: (link: http://cvs.php.net/viewvc.cgi/pecl/memcached/memcached-api.php? View = markup)

Developed as an engine rather than a new API, mysqlnd enables a large number of applications to use the new engine without making changes to the database operations. If mysqlnd is a new extension, it faces a difficult choice if it wants to be compatible with previous programs. So far, there are three official sets of MySQL classes that use libmysql and have different external interfaces. If mysqlnd is compatible with mysql, it is not compatible with mysqli or pdo. Of course, for programs that use their own abstract database classes, this can be achieved by rewriting the classes or changing the driver(PHP level). But think about it, even using abstract libraries, there are so many database abstract libraries in the world, if we want to make nd affordable for everyone, how many libraries we have to change, and how many drivers.

The situation with memcached is much simpler. The only thing that is officially related to memcache is pecl::memcache. They can all be thought of as different drivers in an abstract class. So it's two different sets of clients, but you don't have to change much to replace them, just change the class initialization, flag set/get, etc., unless you're using a non-oo interface.

In addition, mysql in communication and data acquisition is also more complex than memcache, nd can do some things that libmysql can not do. For example, the buffer can be stored directly using the internal HashTable and zval in PHP. For example, some structures that are persistent links can be cached more. (these examples are just my guesses, I haven't read the mysqlnd code)

Memcached manual:

(link: http://cn.php.net/manual/en/book.memcached.php)

Memcache manual:

(link: http://cn.php.net/manual/en/book.memcache.php)

(link: #)


Related articles: