6

如何格式化以下 Redis 连接字符串:

连接字符串:myIP,keepAlive=180,ConnectRetry=30,ConnectTimeout=5000

我开始编写单元测试,但不断收到输入字符串格式不正确的错误消息

 [TestFixtureSetUp]
        private void Init()
        {
            var redisConnectionString = "myIP,keepAlive=180,ConnectRetry=30,ConnectTimeout=5000";                
         _clientsManager = new PooledRedisClientManager(redisConnectionString);

        }

        [Test]
        public void CanConnectToRedis()
        {
            var readWrite = (RedisClient) _clientsManager.GetClient();
            using (var redis = _clientsManager.GetClient())
            {
                var redisClient = redis;

            }
        }
4

1 回答 1

6

查看ServiceStack.Redis 主页上的连接字符串格式:

redis://localhost:6379?ConnectTimeout=5000&IdleTimeOutSecs=180

可以在任何Redis 客户端管理器中使用:

var redisManager = new RedisManagerPool(
    "redis://localhost:6379?ConnectTimeout=5000&IdleTimeOutSecs=180");
using (var client = redisManager.GetClient())
{
    client.Info.PrintDump();
}

可用的配置选项列表也列在主页上

于 2015-03-11T17:29:42.793 回答