How to delete lots of related keys at once

Jarom Severson j.severson at yahoo.com
Fri Aug 3 00:29:53 UTC 2007


My main confusion or concern with memcache is how to
go about deleting a given set of keys in the
cache. For instance, we probably have 10-15 pages on
our site that hit the "articles" tables in our
database. So, that right there would be 10-15 unique
key/value pairs in memcache, assuming I store the
query as the key, and the result set as the value. Now
add on dynamic search strings, pagination, etc, and
you've probably got 100 unique key/value pairs in
memcache, all pertaining to articles.

So my question is, if we want to make sure our site is
never stale, then we need to invalidate all 100 of
those keys if someone inserts a new article. Now I'm
thinking I need to do a search in my keys to find all
article related keys and invalidate them.

Is the best way to do this then to store ANOTHER key
value pair which essentially stores all the article
related keys as its value? So that I can quickly and
easily invalidate the 100 other keys?

It seems like this might be what "namespaces" are for,
but I can't understand the example given on the
memcached FAG page.

Any help and direction in this area would be much
appreciated, or any other good articles I should read
that talk about best practices, implementation
techniques, etc.

thanks in advance.

Jay



More information about the memcached mailing list