ServiceStack.Redis连接阿里云redis服务时使用连接池出现的问题

创建连接池

      private static PooledRedisClientManager prcm = CreateManager(new string[] { "password@ip:port" }, new string[] { "password@ip:port" });
public static PooledRedisClientManager CreateManager(string[] readWriteHosts, string[] readOnlyHosts)
{
//支持读写分离,均衡负载
return new PooledRedisClientManager(readWriteHosts, readOnlyHosts, new RedisClientManagerConfig
{
MaxWritePoolSize = ,//“写”链接池链接数
MaxReadPoolSize = ,//“读”链接池链接数
AutoStart = true,
DefaultDb =
});
}

调用

using (IRedisClient Redis = prcm.GetClient()) {
Redis.Set(key, value, dateTime);
}

这是会出现错误  command role not support for your account

解决方案:

在创建连接池的时候 加入这样一句代码  RedisConfig.VerifyMasterConnections = false;

 public static PooledRedisClientManager CreateManager(string[] readWriteHosts, string[] readOnlyHosts)
{
RedisConfig.VerifyMasterConnections = false;
//支持读写分离,均衡负载
return new PooledRedisClientManager(readWriteHosts, readOnlyHosts, new RedisClientManagerConfig
{
MaxWritePoolSize = ,//“写”链接池链接数
MaxReadPoolSize = ,//“读”链接池链接数
AutoStart = true,
DefaultDb =
});
}

问题解决!

另外一个错误

NOAUTH Authentication required

解决方法

private static PooledRedisClientManager prcm = CreateManager(new string[] { "password@ip:port" }, new string[] { "password@ip:port" });

上一篇:使用99元一年的256MB高性能阿里云Redis加速Discuz论坛


下一篇:Socurce Insight 快捷键