Esempio n. 1
0
 public override void Dispose()
 {
     if (manageClientManagerLifetime)
     {
         clientManager.Dispose();
     }
 }
 public static void CloseClients()
 {
     if (_manager != null)
     {
         _manager.Dispose();
         _manager = null;
     }
 }
 public void OnBeforeEachTest()
 {
     if (redisManager != null)
     {
         redisManager.Dispose();
     }
     redisManager = new BasicRedisClientManager(TestConfig.SingleHost);
     redisManager.Exec(r => r.FlushAll());
 }
Esempio n. 4
0
 public void OnBeforeEachTest()
 {
     if (redisManager != null)
     {
         redisManager.Dispose();
     }
     redisManager = TestConfig.BasicClientManger;
     redisManager.Exec(r => r.FlushAll());
 }
Esempio n. 5
0
        public static void CloseClients()
        {
            if (_manager != null)
            {
                _manager.Dispose();
                _manager = null;

                LogManager.Log("Closing Connection to Redis server...", LogSeverity.Information);
            }
        }
 public void Dispose()
 {
     ////TEAR DOWN
     using (var redisClient = RedisClientsManager.GetClient())
     {
         redisClient.SortedSets[RedisTimeoutPersistenceTests.EndpointName].Clear();
         var allKeys = redisClient.ScanAllKeys(RedisGatewayPersistenceTests.EndpointName + "*");
         redisClient.RemoveAll(allKeys);
     }
     RedisClientsManager.Dispose();
 }
        private void ResetConnections()
        {
            if (clientManager != null)
            {
                clientManager.Dispose();
                clientManager = null;
            }

            if (factory != null)
            {
                factory.Dispose();
                factory = null;
            }

            clientManager = new BasicRedisClientManager(TestConfig.MasterHosts);
            factory       = new RedisTransientMessageFactory(clientManager);
        }
        /// <summary>
        /// 建立连接池
        /// </summary>
        private void CreateManager()
        {
            // 读取Redis主机IP配置信息
            // 有密码的格式:redis:[email protected]:6379
            // 无密码的格式:127.0.0.1:6379
            var pools = zkhelper.pools;

            string[] redisMasterHosts = pools.Select(m => m.Addr).ToArray();
            // 如果Redis服务器是主从配置,则还需要读取Redis Slave机的IP配置信息
            string[] redisSlaveHosts = null;
            //string slaveConnection = null;
            //if (!string.IsNullOrWhiteSpace(slaveConnection))
            //{
            //    redisSlaveHosts = slaveConnection.Split(',');
            //}

            var redisClientManagerConfig = new RedisClientManagerConfig
            {
                MaxWritePoolSize = maxWritePoolSize,
                DefaultDb        = defaultDb,
                AutoStart        = true
            };

            // 创建Redis连接池
            if (Manager != null)
            {
                Manager.Dispose();
                log.InfoFormat("销毁Redis连接池完成");
            }

            #region 只为打日志
            string redisMasterHostsStr = "";
            foreach (var itemHost in redisMasterHosts)
            {
                redisMasterHostsStr += itemHost + ",";
            }
            log.InfoFormat("创建Redis连接池,RedisMasterHosts:{0}", redisMasterHostsStr.TrimEnd(','));
            #endregion 只为打日志

            Manager = new PooledRedisClientManager(redisMasterHosts, redisSlaveHosts, redisClientManagerConfig)
            {
                PoolTimeout    = 2000,
                ConnectTimeout = 1000
            };
        }
Esempio n. 9
0
 public void ClearData()
 {
     using (var client = _pool.GetClient())
         client.FlushAll();
     _pool.Dispose();
 }
Esempio n. 10
0
 public void TestSetUp()
 {
     if (redisManager != null) redisManager.Dispose();
     redisManager = TestConfig.BasicClientManger;
     redisManager.Exec(r => r.FlushAll());
 }
Esempio n. 11
0
 protected void Application_OnEnd()
 {
     ClientsManager.Dispose();
 }
 public void TestFixtureTearDown()
 {
     mqService.Dispose();
     redisManager.Dispose();
 }
 public void Dispose()
 {
     wrappedClientManager.Dispose();
 }
 /// <summary>
 /// Dispose DB connection 释放DB相关链接
 /// </summary>
 public void DbConnectionStop()
 {
     _redisClient.Dispose();
 }
Esempio n. 15
0
 public void Dispose()
 {
     _manager?.Dispose();
     _sentinel?.Dispose();
 }