static RedisHelperClient() { if (RedisConfig.GetInstance().RedisSwitch) { Redis = ConnectionMultiplexer.Connect(RedisConfig.GetInstance().RedisConnStr); db = Redis.GetDatabase(int.Parse(RedisConfig.GetInstance().RedisDB)); } }
/// <summary> /// 初始化 /// </summary> /// <returns></returns> public static RedisHelperClient GetInstance() { if (uniqueInstance == null) { lock (locker) { // 如果类的实例不存在则创建,否则直接返回 if (uniqueInstance == null) { uniqueInstance = new RedisHelperClient(); Redis = ConnectionMultiplexer.Connect(RedisConfig.GetInstance().RedisExchangeHosts); db = Redis.GetDatabase(int.Parse(RedisConfig.GetInstance().RedisDB)); } } } return(uniqueInstance); }
/// <summary> /// 构造缓存key /// </summary> /// <param name="oldKey"></param> /// <returns></returns> private static string AddSysCustomKey(string oldKey) { return(RedisConfig.GetInstance().SysCustomKey + oldKey); }
/// <summary> /// 构造缓存key /// </summary> /// <param name="oldKey"></param> /// <returns></returns> private static string AddSysCustomKey(string oldKey) { return($"{RedisConfig.GetInstance().RedisKey}-{oldKey}"); }