I'm looking for a simple answer to a simple question that is hard to search for.
Does memcache support purging a subset of keys? Or is a purge call always going to flush the entire cache?
More specifically, does PHP's memcached ("d" on the end) client support this? (vs PHP's memcache client, which does not) Does it require support of this on the server?
We have a multi-tenant service that uses a single memcache server for all tenants. To do this, we prefix keys with a unique tenant identifier. We'd like to be able to flush keys per-tenant, but it looks like memcache's purge only supports purging the entire cache.
Best Answer
To formalize this into an answer,
memcached
does not offer such a feature that I'm aware of, and you're going to have to do this yourself. See sample frommemcached
's Google Code page.On a side note, Drupal a PHP based CMS, has a
memcached
module which allows for prefixes and cache purges. We have used it successfully to purge cache by prefix in our setup. While I've not examined the code for this module recently, it would be worth looking at (see 7.x-1.0 version). And, perhaps, you will find thismemcached
QA of mine on Drupal SE: Using Memcache Effectively with Drupal 7 Multisite useful as well.