Regex on memcached key?

孤街浪徒 提交于 2019-12-23 17:37:29

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!