I'm using memcache in my rails app. I want to say
expire all the entries with keys like 'foo-123-*'
Where * is any string. Of course, no memcache distribution supports this directly (right?) because it's built to be simple and fast so it doesn't have indexes.
There are a couple projects that sort of address this, by keeping a local list of keys:
- https://github.com/defconomicron/dalli-store-extensions
- https://github.com/jkassemi/memcache-store-extensions
But in keeping the list in memory… that list can become out of sync between application instances… so it's not reliable.
Has this problem been solved in another way? Am I missing a common solution?
as you said, query memcached like you want is not possible... but here is a php example i found that returns key list
http://snipt.org/xtP
it sends
and than iterate returned items and sends
42 is item number, 100 is number of items to return
then you can iterate through returned keys and delete keys that you don't need any more.
(but this is an ugly workaround anyway...)