PHP memcache and memcached two pecl library _php tutorials

Source: Internet
Author: User
Tags php framework
Before trying to use the memcache, later found that memcached support Setmulti method, ready to turn to use the memcached library.

(tried, in fact, memcache from the support of multi-valued set, but not on the document, see Changelog seems to be 3.0 start support, stable version may not have this feature.) )

As for efficiency, it is unclear how big the gap will be.

One article here also says that Memcached is based on libmemcached and may be better.

Finally, libmemached-based PHP extensions were released in Pecl.

So, now there are two memcache clients on the pecl. One is the memcache developed entirely within the PHP framework, one using the libmemcached memecached.

function, I have not seen libmemcached, but theoretically, in other languages already very popular libmemcached should have more perfect function. While the program performance (memory and CPU usage), not to say, although the pecl::memcache is native implementation, but the use of libmemcached pecl::memached only support Oo interface, and pecl:: Memcache is the OO and non-oo two sets of interfaces coexist, this is a drag on it.

In fact, these are not the most important. The use of libmemcached has an obvious advantage, is that later with the memcached server-side improvements, this LIB will certainly follow up immediately. Pecl::memcache is not necessarily able to follow up on time.

Pecl::memcached, there is also a very good place to be praised, that is, flag is not in the operation of the time set. Instead, there is a unified setoption (). In this way, it is worthwhile to go from Pecl::memcache to pecl::memcached. The specific interface can be seen here: http://cvs.php.net/viewvc.cgi/pecl/memcached/memcached-api.php?view=markup

I mentioned in the pecl-dev@ whether I could make a driver-based architecture. As with current MySQL, you can choose to use MYSQLND or libmysql as the underlying engine. But then think about it, I don't really support the use of this architecture for memcached, which is not the same as the MySQL situation.

MYSQLND is developed as an engine rather than as a new API, which allows a large number of applications to use the new engine without modifying the database operations. If MYSQLND as a new extension, then it faces a difficult choice if it wants to be compatible with previous programs. Because so far, there are 3 official MySQL class sets that use Libmysql and have different external interfaces. MYSQLND can be compatible with MySQL, mysqli or PDO is not compatible. Of course, for programs that use their own abstract database classes, this can be done by rewriting the class or replacing the driver (PHP layer) for compatibility. But to think, even if the use of abstract libraries, the world so many database abstraction library, if you want to make everyone can use the ND, how many libraries, plus how many driver ah.

Memcached the situation is much simpler, the current and official relations are relatively close to only Pecl::memcache, and the interface is basically based on memcached protocol, and Libmemcache almost. They can actually be seen as different driver in an abstract class. So although the two sets of different clients, but replaced, almost no need to make any changes, just need to change in the class initialization, set/get and so on, and so on the flag of these methods can be removed, unless you use a non-OO interface.

In addition MySQL in the communication and data acquisition is also more complex than memcache, ND can do something libmysql can't do. For example, buffer can be stored directly inside PHP hashtable and Zval, and for example, some structures that are persistent links can be cached more. (These are just my guesses, I haven't read the code for MYSQLND)

Memcached Manual:

http://cn.php.net/manual/en/book.memcached.php

Memcache Manual:

http://cn.php.net/manual/en/book.memcache.php

Memcached agreement in English-Chinese comparison

http://www.bkjia.com/PHPjc/321430.html www.bkjia.com true http://www.bkjia.com/PHPjc/321430.html techarticle before trying to use the memcache, later found that memcached support Setmulti method, ready to turn to use the memcached library. (tried, in fact, memcache from a multi-valued set, but the document also ... )

  • Related Article

    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.