redis各类错误可能的解决方案

1.报Timeout performing EVAL

这个可能是连到读库从库了,直接改成写库就没问题了。

2.

各种ConnectTimeout

一般是偶尔或经常就超时,这种情况,找了各种回答,最后在stackoverflow上看到一个大佬给了个解决方法,试了下,可以了。

对应地址:https://stackoverflow.com/questions/23160094/stackexchange-redis-connectionmultiplexer-connect-intermittently-works

内容是:

I could solve the above by doing this :

The error you are getting is usually a sign that you have not set abortConnect=false in your connection string. The default value for abortConnect is true, which makes it so that StackExchange.Redis won't reconnect to the server automatically under some conditions. We strongly recommend that you set abortConnect=false in your connection string so that SE.Redis will auto-reconnect in the background if a network blip occurs.

Source : https://stackoverflow.com/a/30918632/2236811

So my init() looked like this

 ConfigurationOptions co = new ConfigurationOptions()
        {
            SyncTimeout = 500000,
            EndPoints =
            {
                {url,portNumber }
            },
            AbortOnConnectFail = false // this prevents that error
        };

        seClient = ConnectionMultiplexer.Connect(co);

 

thanks

以上。如果看不懂英文不要紧,把代码复制去用就行了。

比如我是这样写的:

192.168.0.1:6379,abortConnect=false,syncTimeout=500000

这样子就可以了。

 

 

以上所有redis操作用的都是:StackExchange.Redis  来进行的。

转载于:https://www.cnblogs.com/qiywtc/p/9318158.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值