添加操作

This commit is contained in:
橙子
2022-04-10 19:25:49 +08:00
parent 538dd0eeac
commit c77db1a2f9

View File

@@ -22,19 +22,8 @@ namespace Yi.Framework.Core
{ {
this._RedisOptions = redisConnOptions.CurrentValue; this._RedisOptions = redisConnOptions.CurrentValue;
} }
//public CSRedisClient GetClient()
//{
// return client;
//}
//private CSRedisClient client=null;
// 为了以后全链路做准备
private T TryCatch<T>(MyAction<T> action) private T TryCatch<T>(MyAction<T> action)
{ {
//Stopwatch sw = Stopwatch.StartNew();
////Exception ex = null;
////bool isError = false;
var client2 = new CSRedisClient($"{_RedisOptions.Host}:{_RedisOptions.Prot},password={_RedisOptions.Password},defaultDatabase ={ _RedisOptions.DB }"); var client2 = new CSRedisClient($"{_RedisOptions.Host}:{_RedisOptions.Prot},password={_RedisOptions.Password},defaultDatabase ={ _RedisOptions.DB }");
T result; T result;
try try
@@ -45,9 +34,7 @@ namespace Yi.Framework.Core
{ {
object p = null; object p = null;
result = (T)p; result = (T)p;
//isError = true;
Console.WriteLine(exinfo); Console.WriteLine(exinfo);
} }
finally finally
{ {
@@ -81,5 +68,9 @@ namespace Yi.Framework.Core
{ {
return this.TryCatch<bool>((u) => u.Set(key, data)); return this.TryCatch<bool>((u) => u.Set(key, data));
} }
public bool AddHash<T>(string key,string field, T data)
{
return this.TryCatch<bool>((u)=>u.HSet(key ,field,data));
}
} }
} }