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.

JDS
  • 2,508
  • 4
  • 29
  • 48
  • 1
    You may have to do this yourself: https://code.google.com/p/memcached/wiki/NewProgrammingTricks#Deleting_By_Namespace – KM. Jan 09 '14 at 16:38

1 Answers1

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.

KM.
  • 1,746
  • 2
  • 18
  • 31
  • 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 09 '14 at 21:57
  • We use `memcached` PHP extension – KM. Jan 09 '14 at 22:05