Home >Backend Development >PHP Tutorial >php memcached extension timeout problem_PHP tutorial
When using the memcached extension in php to access memcached, when the memcached server cannot connect normally, the request response will be slowed down under the default settings. Note: Failure to connect normally refers to network failure, such as the inability of two servers to communicate. As long as the ping is successful, even if the memcached service is not turned on or down, the response time will not be affected, but memcached will not start.
The timeout setting is controlled by the constant Memcached::OPT_CONNECT_TIMEOUT. The default is 4000 milliseconds (the official PHP website shows 1000, and my test versions 1.0.2 and 2.0.1 are both 4000). In addition, there is a big difference between 1.0.2 and 2.0.1. 1.0.2 will connect to the memcached server when executing addServer, and it takes 2 times the timeout time to execute the command. Therefore, when memcached cannot connect, the time spent is 3 times the timeout time.
2.0.1 seems to have a bug in PHP 5.2 and cannot be used. For details, please refer to: https://bugs.php.net/bug.php?id=61283.