8

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;

            }
        }
user1526912
  • 15,818
  • 14
  • 57
  • 92

1 Answers1

7

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.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • This returns an input string with incorrect format error.var redisConnectionString = "redis://localhost:6379?ConnectTimeout=5000&IdleTimeOutSecs=180"; – user1526912 Mar 11 '15 at 17:52
  • @user1526912 I just added working code above. If you're not already upgrade to the latest version of the ServiceStack Redis Client. – mythz Mar 11 '15 at 18:47
  • I am using ServiceStack version 4.030319 and stil encountering this error – user1526912 Mar 11 '15 at 20:45