public static function ClientFactory::getClientInterface in Redis 8
Lazy instantiates client proxy depending on the actual configuration.
If you are using a lock or cache backend using one of the Redis client implementations, this will be overridden at early bootstrap phase and configuration will be ignored.
Return value
File
- src/
ClientFactory.php, line 99
Class
- ClientFactory
- Common code and client singleton, for all Redis clients.
Namespace
Drupal\redisCode
public static function getClientInterface() {
if (!isset(self::$_clientInterface)) {
$settings = Settings::get('redis.connection', []);
if (!empty($settings['interface'])) {
$className = self::getClass(self::REDIS_IMPL_CLIENT, $settings['interface']);
self::$_clientInterface = new $className();
}
elseif (class_exists('Predis\\Client')) {
// Transparent and arbitrary preference for Predis library.
$className = self::getClass(self::REDIS_IMPL_CLIENT, 'Predis');
self::$_clientInterface = new $className();
}
elseif (class_exists('Redis')) {
// Fallback on PhpRedis if available.
$className = self::getClass(self::REDIS_IMPL_CLIENT, 'PhpRedis');
self::$_clientInterface = new $className();
}
else {
if (!isset(self::$_clientInterface)) {
throw new \Exception("No client interface set.");
}
}
}
return self::$_clientInterface;
}