如何格式化以下 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;
}
}
连接字符串格式参见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();
}
主页上还列出了可用配置选项列表。