How to format ServiceStack Redis connection string
Asked Answered
S

1

12

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;

            }
        }
Siberia answered 11/3, 2015 at 16:26 Comment(0)
R
12

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 configuration options are also listed on the homepage.

Rustcolored answered 11/3, 2015 at 17:29 Comment(3)
This returns an input string with incorrect format error.var redisConnectionString = "redis://localhost:6379?ConnectTimeout=5000&IdleTimeOutSecs=180";Siberia
@Siberia I just added working code above. If you're not already upgrade to the latest version of the ServiceStack Redis Client.Rustcolored
I am using ServiceStack version 4.030319 and stil encountering this errorSiberia

© 2022 - 2024 — McMap. All rights reserved.