multiple namespaces/caching indexes

Harry McIntyre mcintyre321 at
Tue Mar 6 18:20:12 UTC 2007

 Hello mailing list!

I'm currently attempting to implement memcached for our site, and am trying
to do some thing which may or may not be possible. I thought someone here
might be able to help.

I have implemented a wrapper for the memcached client which adds basic
namespacing to memcached as per the method posted by Brian Moon at I was
wondering if this can be extended to allow multiple namespaces for a key,
each of which can expire the cache. An example situation would be that I
have cached a message board for a user. I wish to invalidate this if either
a/ the users security settings change or b/ a thread is posted to the
message board.

I think the solution lies with doing a lookup for the query, and returning
an array of keys of the namespaces used for that query, then doing memcached
lookups for each of those keys, and building a final key up from the results
of those lookups which should point to the cached object. Does that make

My other issue concerns caching look-ups.

Imagine I have a table Users, which I wish to resolve to a User object,
using any of several indexes (id, email, username). I want to cache the fact
that, for example, email address 'abc at' points to the user object
with id 123 etc. etc.

Whe my invalidation trigger runs, and I invalidate the namespace for the
updated row, do I also need to update all the cached index lookups, or is
there a clever way to do it using a namespace? I can't figure one out, but I
also think there should be a clever way.

cheers everyody,

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the memcached mailing list