检索缓存中的所有项目
我最近启动并运行了 Enyim Memcached
,它运行得很好。使用该库,我可以毫无问题地存储和检索项目。
但是,我想知道是否有一种方法可以从缓存中检索所有项目。 我知道您可以通过其键检索项目:
MemcachedClient client = new MemcachedClient()
object o = client.Get("key");
但我似乎看不到 GetAll()
或类似的方法,我是否遗漏了什么?
I have recently got Enyim Memcached
up and running and it is working great. Using the library I am able to store and retrieve items with no problem.
However, I was wondering if there was a way to retrieve all items from the cache.
I am aware that you are able to retrieve an item by its key:
MemcachedClient client = new MemcachedClient()
object o = client.Get("key");
But I can't seem to see a GetAll()
or similar method, am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想详细说明dasun的答案。他是正确的,没有办法从标准 memcached 中获取所有密钥,但是还有其他风格的 memcached 允许您通过 Tap 流来执行此操作。如果您使用 Membase 服务器(如果您只使用缓存桶,Membase 几乎就是 memcached),您可以执行此操作,或者您可以使用 memcached 的 Membase 分支,可以在此处找到 https://github.com/membase/memcached。 Membase 分支绝对可以安全使用,许多顶级 memcached 贡献者都为 Membase(现在的 Couchbase)工作,并将该分支的内容贡献回主 memcached 分支。
另外需要注意的是,Enyim 客户端不支持 tap API,但有 Java、C/C++、python 和 ruby 客户端支持 tap。您要做的是创建一个 Tap Dump 流,该流将向您发送所有键值对 memcached/Membase。
I want to elaborate on dasun's answer. He is correct that there is no way to get all keys out of standard memcached, however there are other flavors of memcached that allow you to do this through tap streams. You can do this if you use Membase server (If you just use cache buckets Membase is pretty much just memcached) or you can use the Membase branch of memcached which can be found here https://github.com/membase/memcached. The Membase branch is definitely safe to use and many of the top memcached contributors work for Membase (now Couchbase) and contribute stuff from this branch back to the main memcached branch.
On another note, the Enyim client doesn't support the tap API, but there are Java, C/C++, python, and ruby client that support tap. What you would do is a create a tap dump stream and this stream would send you all of the key value pairs memcached/Membase.
不,你不能。 Memchached 并不是为此目的而设计的(缓存并不意味着检索所有项目,这是毫无意义的)。
No, You can't. Memchached is not designed for that purpose(Caching not meant to retrieve all item, which is pointless).