云redis,ServiceStack.Redis連接阿里云redis服務時使用連接池出現的問題

 2023-12-06 阅读 26 评论 0

摘要:創建連接池 1      private static PooledRedisClientManager prcm = CreateManager(new string[] { "password@ip:port" }, new string[] { "password@ip:port" }); 2 public static PooledRedisClientManager CreateManager(string[] readW

創建連接池

 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

云redis,解決方案:

在創建連接池的時候 加入這樣一句代碼? 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         }

問題解決!

redis集群自建還是用阿里云。?

另外一個錯誤

NOAUTH Authentication required

解決方法

阿里云可以跑mapreduce嗎、private static PooledRedisClientManager prcm = CreateManager(new string[] { "password@ip:port" }, new string[] { "password@ip:port" });

轉載于:https://www.cnblogs.com/wang0020/p/8991852.html

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/1/191197.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息