| | |
| | | using StackExchange.Redis; |
| | | using System.Linq; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | using WIDESEAWCS_RedisService.Options; |
| | | |
| | | namespace WIDESEAWCS_RedisService.Connection |
| | |
| | | |
| | | var connection = ConnectionMultiplexer.Connect(configOptions); |
| | | connection.ConnectionFailed += (_, e) => |
| | | ConsoleHelper.WriteErrorLine($"Redis连接失败: {e.FailureType}"); |
| | | QuartzLogger.Info($"Redis连接失败: {e.FailureType}"); |
| | | connection.ConnectionRestored += (_, e) => |
| | | ConsoleHelper.WriteSuccessLine($"Redis连接恢复: {e.EndPoint}"); |
| | | QuartzLogger.Info($"Redis连接恢复: {e.EndPoint}"); |
| | | |
| | | ConsoleHelper.WriteSuccessLine($"Redis连接成功: {string.Join(",", configOptions.EndPoints)}"); |
| | | QuartzLogger.Info($"Redis连接成功: {string.Join(",", configOptions.EndPoints)}"); |
| | | return connection; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ConsoleHelper.WriteErrorLine($"Redis连接创建失败:{ex.Message}"); |
| | | QuartzLogger.Error($"Redis连接创建失败:{ex.Message}",null, ex); |
| | | throw; |
| | | } |
| | | } |