You are here

public static function Redis_Client::getClientInterfaceName in Redis 7.3

Find client class name

Return value

string

3 calls to Redis_Client::getClientInterfaceName()
Redis_Client::getClass in lib/Redis/Client.php
Get specific class implementing the current client usage for the specific asked core subsystem.
redis_help in ./redis.module
Implements hook_help().
redis_requirements in ./redis.install
Implements hook_requirements().

File

lib/Redis/Client.php, line 179

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 getClientInterfaceName() {
  global $conf;
  if (!empty($conf['redis_client_interface'])) {
    return $conf['redis_client_interface'];
  }
  else {
    if (class_exists('Predis\\Client')) {

      // Transparent and abitrary preference for Predis library.
      return $conf['redis_client_interface'] = 'Predis';
    }
    else {
      if (class_exists('Redis')) {

        // Fallback on PhpRedis if available.
        return $conf['redis_client_interface'] = 'PhpRedis';
      }
      else {
        throw new Exception("No client interface set.");
      }
    }
  }
}