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

你可能感兴趣的:(redis各类错误可能的解决方案)