PHP 的两个 memcache 扩展:memcache 和 memcached


在Q群里问了下,没有人能分辨出它们的差别,甚至有人怀疑我说的 Memcached 是 Memcached 服务器(守护进程)。

从手册上看,memcached 会比 memcache 多几个方法,使用方式上都差不多。


Memcached client library was just recently released as stable. It is being used by digg ( was developed for digg by Andrei Zmievski, now no longer with digg) and implements much more of the memcached protocol than the older memcache client.

memcached 实现了更多的 memcached 协议(毕竟是基于 libmemcached 库的)。

As Nate’s link suggests, both work perfectly well for simple usage. However, memcached supports more features that allow you to get the most performance out of memcached. The binary protocol reduces the amount of data required to be sent between client and server. Multigets and multisets allow you to get/set multiple items at the same time. If you’re finding you need more oomph out of memcache, memcached is the better module. The use of libmemcached suggests that the library itself is possibly more optimised than the PHP only version.

Memcached is a more recent module compared to memcache, having only been released 8 months ago. If you need to target an older version of PHP, then you can only really use memcache.

memcached 的版本比较新,而且使用的是 libmemcached 库。libmemcached 被认为做过更好的优化,应该比 php only 版本的 memcache 有着更高的性能。

这里有另外一个对比表,很明显,用 memcached 会让人放心很多:
差别比较大的一点是,memcached 支持 Binary Protocol,而 memcache 不支持,意味着 memcached 会有更高的性能。不过,还需要注意的是,memcached 目前还不支持长连接:

pecl/memcached does not support failover or persistent connections. This is quite annoying, since I’m sure the underlying libmemcached C library supports both.

pecl/memcache does not have the very handy getServerByKey() method, which is immensely useful when debugging.

在这里,我推荐大家使用 memcached :)

— EOF —

《PHP 的两个 memcache 扩展:memcache 和 memcached》有27个想法

  1. google过来的,看来memcached的扩展的性能更强一些,不过centos6.2的yum源里么有安装包。!

  2. When I originally commented I appear to have clicked the -Notify me when new comments are added- checkbox and from now on whenever a comment is added I receive four emails with the exact same comment. There has to be a way you can remove me from that service? Many thanks!

    1. Ditto on Casey and Tim; this fix worked beitlafuuly on Slackware 14, and.borken tmux is now worken tmux. I’m thrilled the first Google result was actually a fifteen-second fix.Thanks so much Nigel. Cheers!

    2. A couple of notes, snzitiae your request variables before pulling data directing into you code. Avoid using double quote for simple string echo as it is extra load on php parsing use single quote instead. Play with MVC type frameworks such as Zends framework to get familiar with design patterns. Nice tutorial for beginners but be warned, I had to fire a bunch of people recently who programmed like this go back to programming basics and learn popular framework methodologies.

  3. Heinonen, es entre los fisiólogos del ejercicio más
    vanguardistas del mundo; aconseja que debido a que el ejercicio no fomenta la
    pérdida de carnitina afecta los niveles de carnitina, no hay razón para su ingestión de forma suplementaria
    (veinte). Para aquellos (sobre todo ciclistas) que pasan por alto las investigaciones efectuadas, examinemos
    la información que directamente ha apoyado la suplementación con carnitina.

    1. Steve-Barry Moser is fantastic! We have his Bible and it is absolutely exquisite. (I am looking forward to adding R. Crumb's edition to my collection;) Barry has also done &#39A;lice's Adventures in Wonderland', and I believe 'Through the looking Glass' as well.Thanks for the info on Jim Horton.-RQ

  4. Lhasa is an amazing journey in the dreams of many to undertake one day.

    A great way to go there is by train from either Shanghai,
    Chengdu or Beijing.
    I would recommend this method of transport because of
    the fact you can adjust to the higher than normal altitude.

    If yyou fly in on the other hand the adjustment is to fast
    for many and will feel sick and not be able to do their trip.

    It takes anywhere from 45-60hours depending on the season and unexpected occurances.

    Many tours companies offer deals for this amazing trip as we
    do also. You will be pleased to know we only work with locals.

    Putting money back in the pockets of the Tibet people. It is also an amzing spirtual journey for
    Welcome to book with us anytime.

    1. Si t’es super bordélique pis que t’entends ne pas rester célibataire…T’es mieux de regler ton probleme avant d’chercher…Parce que l’monde que l’bordel ne dérange ja&0ism#8230;&#823a;…..Tu veux aps nécessairement avoir ca dans ton lit

  5. Unquestionably imagine that which you stated. Your favorite justification appeared to be at the internet the simplest factor to take into account of. I say to you, I definitely get irked while other folks think about concerns that they just don’t realize about. You managed to hit the nail upon the top and outlined out the entire thing with no need side-effects , people could take a signal. Will likely be again to get more. Thank you|

  6. Please let me know if you’re looking for a writer for your site.
    You have some really good articles and I feel I would be a good asset.

    If you ever want to take some of the load
    off, I’d love to write some material for your blog in exchange
    for a link back to mine. Please send me an email if interested.


电子邮件地址不会被公开。 必填项已用*标注