$redis->connect('192.168.200.253', 637912,3);
有个疑问,这个3秒是指连接上以后3秒后断开,还是3秒没连接上认为是超时呢?这个连接超时到底是指没连接上的超时还是连接上以后的的超时。
大家讲道理2017-04-24 09:15:48
Generally speaking, the timeout time of the connect function refers to the link waiting time in TCP, that is, the link establishment time is 3 seconds. If the link is not successful in 3 seconds, the function returns.
In addition, by default, the server side of redis will automatically kill the link if there is no access for 5 seconds. The client side is not aware of this. It is best to judge the availability of the connection every time it is used; it is recommended to call it when there is no data access for 5 seconds. Ping/pang mechanism to prevent link failure;
PHPz2017-04-24 09:15:48
There are many PHP drivers for redis => http://redis.io/clients#php I don’t know which one you are using.
But written in the parameters of the connect method, it should be the timeout for establishing the link.
高洛峰2017-04-24 09:15:48
Generally speaking, what comes with connect is the timeout of the connection.