protected $idlePoolSize = 0;
/** @var array (server name => ((connection info array),...) */
- protected $connections = array();
+ protected $connections = [];
/** @var array (server name => UNIX timestamp) */
- protected $downServers = array();
+ protected $downServers = [];
/** @var array (pool ID => RedisConnectionPool) */
- protected static $instances = array();
+ protected static $instances = [];
/** integer; seconds to cache servers as "down". */
const SERVER_DOWN_TTL = 30;
* @since 1.27
*/
public static function destroySingletons() {
- self::$instances = array();
+ self::$instances = [];
}
/**
$this->logger->debug(
'Server "{redis_server}" is marked down for another ' .
( $this->downServers[$server] - $now ) . 'seconds',
- array( 'redis_server' => $server )
+ [ 'redis_server' => $server ]
);
return false;
if ( !$result ) {
$this->logger->error(
'Could not connect to server "{redis_server}"',
- array( 'redis_server' => $server )
+ [ 'redis_server' => $server ]
);
// Mark server down for some time to avoid further timeouts
$this->downServers[$server] = time() + self::SERVER_DOWN_TTL;
if ( !$conn->auth( $this->password ) ) {
$this->logger->error(
'Authentication error connecting to "{redis_server}"',
- array( 'redis_server' => $server )
+ [ 'redis_server' => $server ]
);
}
}
$this->downServers[$server] = time() + self::SERVER_DOWN_TTL;
$this->logger->error(
'Redis exception connecting to "{redis_server}"',
- array(
+ [
'redis_server' => $server,
'exception' => $e,
- )
+ ]
);
return false;
if ( $conn ) {
$conn->setOption( Redis::OPT_READ_TIMEOUT, $this->readTimeout );
$conn->setOption( Redis::OPT_SERIALIZER, $this->serializer );
- $this->connections[$server][] = array( 'conn' => $conn, 'free' => false );
+ $this->connections[$server][] = [ 'conn' => $conn, 'free' => false ];
return new RedisConnRef( $this, $server, $conn, $this->logger );
} else {
$server = $cref->getServer();
$this->logger->error(
'Redis exception on server "{redis_server}"',
- array(
+ [
'redis_server' => $server,
'exception' => $e,
- )
+ ]
);
foreach ( $this->connections[$server] as $key => $connection ) {
if ( $cref->isConnIdentical( $connection['conn'] ) ) {
if ( !$conn->auth( $this->password ) ) {
$this->logger->error(
'Authentication error connecting to "{redis_server}"',
- array( 'redis_server' => $server )
+ [ 'redis_server' => $server ]
);
return false;
$conn->clearLastError();
try {
- $res = call_user_func_array( array( $conn, $name ), $arguments );
+ $res = call_user_func_array( [ $conn, $name ], $arguments );
if ( preg_match( '/^ERR operation not permitted\b/', $conn->getLastError() ) ) {
$this->pool->reauthenticateConnection( $this->server, $conn );
$conn->clearLastError();
- $res = call_user_func_array( array( $conn, $name ), $arguments );
+ $res = call_user_func_array( [ $conn, $name ], $arguments );
$this->logger->info(
"Used automatic re-authentication for method '$name'.",
- array( 'redis_server' => $this->server )
+ [ 'redis_server' => $this->server ]
);
}
} catch ( RedisException $e ) {
$res = $conn->eval( $script, $params, $numKeys );
$this->logger->info(
"Used automatic re-authentication for Lua script '$sha1'.",
- array( 'redis_server' => $server )
+ [ 'redis_server' => $server ]
);
}
// If the script is not in cache, use eval() to retry and cache it
$res = $conn->eval( $script, $params, $numKeys );
$this->logger->info(
"Used eval() for Lua script '$sha1'.",
- array( 'redis_server' => $server )
+ [ 'redis_server' => $server ]
);
}
if ( $conn->getLastError() ) { // script bug?
$this->logger->error(
'Lua script error on server "{redis_server}": {lua_error}',
- array(
+ [
'redis_server' => $server,
'lua_error' => $conn->getLastError()
- )
+ ]
);
}