新增Redis方法
This commit is contained in:
@@ -13,19 +13,15 @@ namespace Common
|
||||
/// </summary>
|
||||
public class CSRedisCacheHelper
|
||||
{
|
||||
public static CSRedisClient? redis;
|
||||
public static CSRedisClient? redis1;
|
||||
|
||||
private const string ip = "10.8.8.208";
|
||||
//private const string port = "6379";
|
||||
private const string port = "10079";
|
||||
public static CSRedisClient redis;
|
||||
private const string ip = "localhost";
|
||||
private const string port = "26379";
|
||||
static CSRedisCacheHelper()
|
||||
{
|
||||
var redisHostStr = string.Format("{0}:{1}", ip, port);
|
||||
if (!string.IsNullOrEmpty(redisHostStr))
|
||||
{
|
||||
redis = new CSRedisClient(redisHostStr + ",password=blw@redis-ser@123,defaultDatabase=0");
|
||||
redis1 = new CSRedisClient(redisHostStr + ",password=blw@redis-ser@123,defaultDatabase=1");
|
||||
redis = new CSRedisClient(redisHostStr + ",password=1001^_^lool,defaultDatabase=0");
|
||||
var DingYueMsg = ("CellCorelDRAWUser", new Action<SubscribeMessageEventArgs>(async (args) =>
|
||||
{
|
||||
string body = args.Body;
|
||||
@@ -91,5 +87,44 @@ namespace Common
|
||||
{
|
||||
return CSRedisCacheHelper.redis.BRPop<T>(3,Key);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加Hash缓存
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
public static void HMSet(string key, params object[] value)
|
||||
{
|
||||
redis.HMSet(key, value);
|
||||
}
|
||||
|
||||
public static void HMSet(int ExpireTime_M, string key, params object[] value)
|
||||
{
|
||||
redis.HMSet(key, value);
|
||||
redis.Expire(key, new TimeSpan(0, ExpireTime_M, 0));
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取Hash缓存
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static T[] HMGet<T>(string key, string KeyV)
|
||||
{
|
||||
return redis.HMGet<T>(key, KeyV);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Example
|
||||
/// WXFault_酒店编号_房间号
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, string> HMGetAll(string key)
|
||||
{
|
||||
return redis.HGetAll(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user