public function Redis_Client_Predis::getClient in Redis 7.2
Same name and namespace in other branches
- 7.3 lib/Redis/Client/Predis.php \Redis_Client_Predis::getClient()
- 7 lib/Redis/Client/Predis.php \Redis_Client_Predis::getClient()
Get the connected client instance.
Return value
mixed Real client depends from the library behind.
Overrides Redis_Client_Interface::getClient
File
- lib/
Redis/ Client/ Predis.php, line 103
Class
- Redis_Client_Predis
- Predis client specific implementation.
Code
public function getClient($host = NULL, $port = NULL, $base = NULL, $password = NULL, $socket = NULL) {
$connectionInfo = array(
'password' => $password,
'host' => $host,
'port' => $port,
'database' => $base,
);
if (!empty($socket)) {
$connectionInfo['scheme'] = 'unix';
$connectionInfo['path'] = $socket;
}
foreach ($connectionInfo as $key => $value) {
if (!isset($value)) {
unset($connectionInfo[$key]);
}
}
// I'm not sure why but the error handler is driven crazy if timezone
// is not set at this point.
// Hopefully Drupal will restore the right one this once the current
// account has logged in.
date_default_timezone_set(@date_default_timezone_get());
$client = new \Predis\Client($connectionInfo);
return $client;
}