Memcache expiration through regex

I am using memcache in my rails application. I want to say

all entries with keys such as "foo-123 - *" expire

Where * is any line. Of course, no memcache distribution supports this directly (right?), Because it is designed to be simple and fast, so it has no indexes.

There are several projects that relate to this address, maintaining a local list of keys:

But when saving the list in memory ... this list may stop synchronizing between instances of the application ... therefore it is not reliable.

Was this problem resolved differently? Did I miss the general solution?

+2
source share
1 answer

as you said, memcached request is not possible as you want ... but here is a php example that I found that returns a list of keys

http://snipt.org/xtP

sends

  • "stats items"

and then iterate the returned items and sends

  • "stats cachedump 42 100"

42 - position number, 100 - number of items to return

then you can iterate over the returned keys and delete the keys that you no longer need.

(but this is an ugly workaround anyway ...)

0
source

All Articles