public function setReadTimeout($timeout)
{
if ($timeout < -1) {
throw new CredisException('Timeout values less than -1 are not accepted.');
}
$this->readTimeout = $timeout;
if ($this->connected) {
if ($this->standalone) {
$timeout = $timeout <= 0 ? 315360000 : $timeout;
// Ten-year timeout
stream_set_blocking($this->redis, TRUE);
stream_set_timeout($this->redis, (int) floor($timeout), ($timeout - floor($timeout)) * 1000000);
} else {
if (defined('Redis::OPT_READ_TIMEOUT')) {
// supported in phpredis 2.2.3
// a timeout value of -1 means reads will not timeout
$timeout = $timeout == 0 ? -1 : $timeout;
$this->redis->setOption(Redis::OPT_READ_TIMEOUT, $timeout);
}
}
}
return $this;
}