如何格式化ServiceStack Redis连接字符串

时间:2015-03-11 16:26:47

标签: redis servicestack.redis

如何格式化以下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;

            }
        }

1 个答案:

答案 0 :(得分:3)

请参阅ServiceStack.Redis home page上的连接字符串格式:

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

可以在任何Redis Client Managers中使用:

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

available configuratoin options are also listed on the homepage的列表。