Memcache替代方案,更多控制

My new PHP application could be sped up with some caching of MySQL results. I have limited experience with memcached, but I don't think it can do what I require.

As I am working on a multi-user application I would like to be able to delete several stored values at once without removing everything.

So I might store:

account_1.value_a = foo
account_1.value_b = bar
account_2.value_a = dog
account_2.value_b = cat

Is there a caching system that would allow me to delete based on a wildcard (or similar method) such as "delete account_1.*" leaving me with:

account_1.value_a = <unset>
account_1.value_b = <unset>
account_2.value_a = dog
account_2.value_b = cat

Thanks, Jim

Not really, but you can fake it by using version numbers in your keys.

For example, if you use keys like this:

{entitykey}.{version}.{fieldname}

So now your account_1 object keys would be:

account_1.1.value_a
account_1.1.value_b

When you want to remove account_1 from the cache, just increment the version number for that object. Now your keys will be:

account_1.2.value_a
account_1.2.value_b

You don't even need to delete the original cached values - they will fall out of the cache automatically since you'll no longer be using them.

This might help: memcache and wildcards

Open source module to get tags for keys in memcache, and other: http://github.com/jamm/memory/

Scache (http://scache.nanona.fi) has nested keyspaces so you could store data on subkeys and expire parent when needed.