php 内存缓存对比 内存缓存
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1825256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Memcache Vs. Memcached
提问by Luca Bernardi
Possible Duplicate:
Using Memcache vs Memcached with PHP
Someone can explain me the difference between Memcache and Memcached in PHP environment? What are the advantages of one over the other? Can you also suggest the criteria used to choose between one or the other?
有人可以解释一下 PHP 环境下 Memcache 和 Memcached 的区别吗?一个比另一个有什么优势?您还可以建议用于在其中一个或另一个之间进行选择的标准吗?
采纳答案by Mez
(PartlyStolen from ServerFault)
(部分从 ServerFault 窃取)
I think that both are functionally the same, but they simply have different authors, and the one is simply named more appropriately than the other.
我认为两者在功能上是相同的,但它们只是有不同的作者,并且一个比另一个更恰当地命名。
Here is a quick backgrounder in naming conventions (for those unfamiliar), which explains the frustration by the question asker: For many *nix applications, the piece that does the backend work is called a "daemon" (think "service" in Windows-land), while the interface or client application is what you use to control or access the daemon. The daemon is most often named the same as the client, with the letter "d" appended to it. For example "imap" would be a client that connects to the "imapd" daemon.
这是命名约定的快速背景知识(对于那些不熟悉的人),它解释了提问者的沮丧:对于许多 *nix 应用程序,执行后端工作的部分称为“守护进程”(想想 Windows 中的“服务”-土地),而接口或客户端应用程序是用来控制或访问守护进程的。守护进程通常与客户端同名,并在其后附加字母“d”。例如,“imap”将是连接到“imapd”守护进程的客户端。
This naming convention is clearly being adhered to by memcache when you read the introduction to the memcache module (notice the distinction between memcache and memcached in this excerpt):
当您阅读 memcache 模块的介绍时,memcache 显然遵守了此命名约定(请注意此摘录中的 memcache 和 memcached 之间的区别):
Memcache module provides handy procedural and object oriented interface to memcached, highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications.
The Memcache module also provides a session handler (memcache).
More information about memcached can be found at ? http://www.danga.com/memcached/.
Memcache 模块为 memcached 提供了方便的面向过程和面向对象的接口,这是一种高效的缓存守护程序,专门用于减少动态 Web 应用程序中的数据库负载。
Memcache 模块还提供了一个会话处理程序(memcache)。
有关 memcached 的更多信息可以在 ? http://www.danga.com/memcached/。
The frustration here is caused by the author of the PHP extension which was badly named memcached, since it shares the same name as the actual daemon called memcached. Notice also that in the introduction to memcached (the php module), it makes mention of libmemcached, which is the shared library (or API) that is used by the module to access the memcached daemon:
这里令人沮丧的是 PHP 扩展的作者,该扩展名被错误地命名为 memcached,因为它与名为 memcached 的实际守护进程共享相同的名称。还要注意,在 memcached(php 模块)的介绍中,它提到了 libmemcached,它是模块用来访问 memcached 守护进程的共享库(或 API):
memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
This extension uses libmemcached library to provide API for communicating with memcached servers. It also provides a session handler (memcached).
Information about libmemcached can be found at ? http://tangent.org/552/libmemcached.html.
memcached 是一种高性能、分布式内存对象缓存系统,本质上是通用的,但旨在通过减轻数据库负载来加速动态 Web 应用程序。
此扩展使用 libmemcached 库提供 API 以与 memcached 服务器通信。它还提供了一个会话处理程序(memcached)。
有关 libmemcached 的信息可以在 ? http://tangent.org/552/libmemcached.html。
回答by Mike Starov
They are not identical. Memcache is older but it has some limitations. I was using just fine in my application until I realized you can't store literal FALSEin cache. Value FALSEreturned from the cache is the same as FALSE returned when a value is not found in the cache. There is no way to check which is which. Memcached has additional method (among others) Memcached::getResultCodethat will tell you whether key was found.
它们并不相同。Memcache 较旧,但有一些限制。我在我的应用程序中使用得很好,直到我意识到你不能FALSE在缓存中存储文字。值FALSE从缓存返回是一样的,当在缓存中找不到假的值返回。没有办法检查哪个是哪个。Memcached 有额外的方法(除其他外)Memcached::getResultCode可以告诉您是否找到了密钥。
Because of this limitation I switched to storing empty arrays instead of FALSEin cache. I am still using Memcache, but I just wanted to put this info out there for people who are deciding.
由于这个限制,我切换到存储空数组而不是FALSE缓存。我仍在使用 Memcache,但我只是想将这些信息发布给正在做决定的人。

