Merge pull request #29 from limingxinleo/redis-timeout

Added some arguments of redis connect.
This commit is contained in:
李铭昕 2019-06-24 22:27:26 +08:00 committed by GitHub
commit 3fa5c8851f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -16,6 +16,9 @@ return [
'auth' => env('REDIS_AUTH', ''),
'port' => (int) env('REDIS_PORT', 6379),
'db' => (int) env('REDIS_DB', 0),
'timeout' => 0.0,
'reserved' => null,
'retry_interval' => 0,
'pool' => [
'min_connections' => 1,
'max_connections' => 10,

View File

@ -62,9 +62,12 @@ class RedisConnection extends BaseConnection implements ConnectionInterface
$port = $this->config['port'] ?? 6379;
$auth = $this->config['auth'] ?? null;
$db = $this->config['db'] ?? 0;
$timeout = $this->config['timeout'] ?? 0.0;
$reserved = $this->config['reserved'] ?? null;
$retryInterval = $this->config['retry_interval'] ?? 0;
$redis = new \Redis();
if (! $redis->connect($host, $port)) {
if (! $redis->connect($host, $port, $timeout, $reserved, $retryInterval)) {
throw new ConnectionException('Connection reconnect failed.');
}