public static ConnectionMultiplexer Instance {
get {
if (_instance == null) {
lock (_locker) {
if (_instance == null || !_instance.IsConnected) {
_instance
= ConnectionMultiplexer.Connect(ConfigUtils.ArrangeResultHost); }
}
}
return _instance; }
}
public static>{return Instance.GetDatabase(); }
//使用Keys *模糊匹配Key public static List<string> GetKeys(string key) {
var result=(string[])GetDatabase().ScriptEvaluate(LuaScript.Prepare("return redis.call('KEYS',@keypattern)"),new{ keypattern=key });
return result.ToList();
}
//使用SCAN模糊匹配Key
public static List<string> GetKeys(string key)
{
var result = (string[])GetDatabase().ScriptEvaluate(
LuaScript.Prepare("local dbsize=redis.call('dbsize') local res=redis.call('scan',0,'match',KEYS[1],'count',dbsize) return res[2]"),
new RedisKey[] { key });
return result.ToList();
}