1

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.

1

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 from memcached'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 this memcached QA of mine on Drupal SE: Using Memcache Effectively with Drupal 7 Multisite useful as well.

  • Our main service is based on Moodle, very similar to your Drupal in most respects. (sorry). Did you use the memcache or memcached PHP extension? – JDS Jan 9 '14 at 21:57
  • We use memcached PHP extension – KM. Jan 9 '14 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.