Listing all keys on a server: why?

Brian Moon brianm at dealnews.com
Thu Jul 27 18:57:49 UTC 2006


> I think a lot of that comes from the lack of namespaces in memcached. 
> You can't just say 'invalidate all cache entries for user jsmith.'  So, 
> an obvious way to work around it is to get a list of active keys, run 
> through them looking for anything that matches 'jsmith' and delete it.

I know it seems hacky, but this works for us quite well:

psuedo code:

user = "jsmith"

key_salt = get(user."_salt)

// get user

key = "user_data_".user."_".key_salt

user = get(key)


// delete all jsmith cache

incr(key_salt)


If you need several salts, just have a few that are loaded on an as 
needed basis in a static or global var depending on your language.

-- 

Brian Moon
-------------
http://dealnews.com/
Its good to be cheap =)


More information about the memcached mailing list