Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format ServiceStack Redis connection string

How can I format the below Redis connection string:

Connection string: myIP,keepAlive=180,ConnectRetry=30,ConnectTimeout=5000

I started writing a unit test but keep getting a input string was not in correct format error message

 [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;

            }
        }
like image 830
user1526912 Avatar asked Mar 11 '15 16:03

user1526912


1 Answers

See the connection string format on the ServiceStack.Redis home page:

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

Which can be used in any of the Redis Client Managers:

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

The list of available configuratoin options are also listed on the homepage.

like image 121
mythz Avatar answered Nov 15 '22 10:11

mythz