Home > Backend Development > PHP Tutorial > PHP怎么设置链接redis的超时时间

PHP怎么设置链接redis的超时时间

PHPz
Release: 2020-06-28 09:40:35
Original
3040 people have browsed it

PHP怎么设置链接redis的超时时间

PHP怎么设置链接redis的超时时间?

问题:

现在是这么连的,有时候redis不稳定,很难连接上,如何设置超时时间?

$this->redis = new Redis();
$this->redis->connect($host, $port);
$this->redis->auth($auth);
Copy after login

方法回答:

$this->redis->connect($host, $port,3); 3秒连接超时

注:这里的问题是设置链接超时时间,一旦连接上,那么只要你不关闭连接,在请求的生命周期中是一直连接着的。

更多相关技术文章,请访问PHP中文网

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template