Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve all items in cache

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?

like image 711
Deano Avatar asked Feb 22 '23 22:02

Deano


2 Answers

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.

like image 131
mikewied Avatar answered Mar 03 '23 07:03

mikewied


No, You can't. Memchached is not designed for that purpose(Caching not meant to retrieve all item, which is pointless).

like image 41
Dasun Avatar answered Mar 03 '23 07:03

Dasun