You are here

public static function Redis_Client::getManager in Redis 7.3

Get client manager

Return value

Redis_Client_Manager

File

lib/Redis/Client.php, line 141

Class

Redis_Client
This static class only reason to exist is to tie Drupal global configuration to OOP driven code of this module: it will handle everything that must be read from global configuration and let other components live without any existence of it

Code

public static function getManager() {
  global $conf;
  if (null === self::$manager) {
    $className = self::getClass(self::REDIS_IMPL_CLIENT);
    $factory = new $className();

    // Build server list from conf
    $serverList = array();
    if (isset($conf['redis_servers'])) {
      $serverList = $conf['redis_servers'];
    }
    if (empty($serverList) || !isset($serverList['default'])) {

      // Backward configuration compatibility with older versions
      $serverList[Redis_Client_Manager::REALM_DEFAULT] = array();
      foreach (array(
        'host',
        'port',
        'base',
        'password',
        'socket',
      ) as $key) {
        if (isset($conf['redis_client_' . $key])) {
          $serverList[Redis_Client_Manager::REALM_DEFAULT][$key] = $conf['redis_client_' . $key];
        }
      }
    }
    self::$manager = new Redis_Client_Manager($factory, $serverList);
  }
  return self::$manager;
}