问题
Is it possible to grab a list of memcached key based on some regex? I understand that one solution is to store the key in the database and grab the list when I need to delete those keys. This means that, it is going to incur additional cost to the db.
I was wondering if there is another way to do it without DB overhead.
Cheers, Mickey
回答1:
No, there's no way to do that. The documentation suggests a way to simulate a namespace, but that's it.
回答2:
memcached is fast because it doesn't do this sort of thing.
If it did all the stuff your database could do, it'd be as fast as your database and someone would need to come along and build something with more constrained semantics that optimized for speed over functionality.
回答3:
private static string CleanKey(string key)
{
var regex = new Regex("[^a-zA-Z0-9-]");
var clean = regex.Replace(key, string.Empty);
return clean.Length > 250 ? clean.Substring(0, 250) : clean;
}
来源:https://stackoverflow.com/questions/2497159/regex-on-memcached-key