创建连接池

 1      private static PooledRedisClientManager prcm = CreateManager(new string[] { "password@ip:port" }, new string[] { "password@ip:port" });
 2         public static PooledRedisClientManager CreateManager(string[] readWriteHosts, string[] readOnlyHosts)
 3         {
 4            //支持读写分离,均衡负载
 5             return new PooledRedisClientManager(readWriteHosts, readOnlyHosts, new RedisClientManagerConfig
 6             {
 7                 MaxWritePoolSize = 5,//“写”链接池链接数
 8                 MaxReadPoolSize = 5,//“读”链接池链接数
 9                 AutoStart = true,
10                 DefaultDb = 0
11             });
12         }

调用

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

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

解决方案:

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

 

 1 public static PooledRedisClientManager CreateManager(string[] readWriteHosts, string[] readOnlyHosts)
 2         {
 3             RedisConfig.VerifyMasterConnections = false;
 4             //支持读写分离,均衡负载
 5             return new PooledRedisClientManager(readWriteHosts, readOnlyHosts, new RedisClientManagerConfig
 6             {
 7                 MaxWritePoolSize = 5,//“写”链接池链接数
 8                 MaxReadPoolSize = 5,//“读”链接池链接数
 9                 AutoStart = true,
10                 DefaultDb = 0
11             });
12         }

问题解决!

 

另外一个错误

NOAUTH Authentication required

解决方法

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

相关文章:

  • 2021-08-11
  • 2021-11-10
  • 2021-12-13
  • 2021-11-16
  • 2022-12-23
  • 2021-04-19
  • 2021-11-22
  • 2021-10-05
猜你喜欢
  • 2022-12-23
  • 2021-12-07
  • 2021-07-15
  • 2021-06-17
  • 2021-12-20
  • 2021-12-14
  • 2021-06-15
相关资源
相似解决方案