Пример #1
0
 private void Connect()
 {
     Console.WriteLine("reconnect");
     while (true)
     {
         try
         {
             _conn = RedisSeConnection.GetConnection(_host);
             if (_conn.IsConnected)
             {
                 Connected = _conn.IsConnected;
                 //_conn.ConnectionFailed += _conn_ConnectionFailed;
                 break;
             }
             Thread.Sleep(100);
         }
         catch
         {
         }
     }
 }
Пример #2
0
        public RedisSe(string host, int db = 0)
        {
            _host = host;
            _db   = db;

            try
            {
                _conn     = string.IsNullOrWhiteSpace(host) ? RedisSeConnection.Instance : RedisSeConnection.GetConnection(host);
                Connected = _conn.IsConnected;
                _conn.ConnectionFailed += _conn_ConnectionFailed;
            }
            catch (Exception)
            {
                new Thread(Connect)
                {
                    IsBackground = true
                }.Start();
                //throw;
            }

            //_conn = string.IsNullOrWhiteSpace(host) ? RedisSeConnection.Instance :RedisSeConnection.GetConnectionMultiplexer(host);
        }