Regex on memcached key?
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 gr开发者_开发问答ab 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
No, there's no way to do that. The documentation suggests a way to simulate a namespace, but that's it.
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.
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;
}
精彩评论