Client timeouts
By default recent versions of Redis don't close the connection with the client if the client is idle for many seconds: the connection will remain open forever.
However if you don't like this behavior, you can configure a timeout, so that if the client is idle for more than the specified number of seconds, the client connection will be closed.
You can configure this limit via redis.conf or simply using CONFIG SET timeout .
如果不关闭客户端连接,它将永远保持打开状态。
https://redis.io/topics/clients
我认为你的redis连接在每次请求时都在实例化,导致它达到最大连接限制,你应该将你的redis实例保持在全局中,这样会共享同一个redis实例,这样就不会再导致太多的连接。redis实例将有自己的连接池,可以通过将max_connections参数设置为redis.connection pool来限制连接数。如果设置了max_connections,则当达到池的限制时,此对象将引发redis.ConnectionError。
相关问题 更多 >
编程相关推荐