You are here

public static function Redis_Client::getDefaultPrefix in Redis 7.3

Get global default prefix

Parameters

string $namespace:

Return value

string

5 calls to Redis_Client::getDefaultPrefix()
Redis_Cache::__construct in lib/Redis/Cache.php
Redis_Lock::getBackend in lib/Redis/Lock.php
Get actual lock backend.
redis_path_backend_get in ./redis.path.inc
Get Redis path lookup backend.
Redis_Tests_Lock_LockingUnitTestCase::createLockBackend in lib/Redis/Tests/Lock/LockingUnitTestCase.php
Create a new lock backend with a generated lock id
Redis_Tests_Path_PathUnitTestCase::getBackend in lib/Redis/Tests/Path/PathUnitTestCase.php
Get cache backend

File

lib/Redis/Client.php, line 94

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 getDefaultPrefix($namespace = null) {
  $ret = null;
  if (!empty($GLOBALS['drupal_test_info']['test_run_id'])) {
    $ret = $GLOBALS['drupal_test_info']['test_run_id'];
  }
  else {
    $prefixes = variable_get('cache_prefix', null);
    if (is_string($prefixes)) {

      // Variable can be a string which then considered as a default
      // behavior.
      $ret = $prefixes;
    }
    else {
      if (null !== $namespace && isset($prefixes[$namespace])) {
        if (false !== $prefixes[$namespace]) {

          // If entry is set and not false an explicit prefix is set
          // for the bin.
          $ret = $prefixes[$namespace];
        }
        else {

          // If we have an explicit false it means no prefix whatever
          // is the default configuration.
          $ret = '';
        }
      }
      else {

        // Key is not set, we can safely rely on default behavior.
        if (isset($prefixes['default']) && false !== $prefixes['default']) {
          $ret = $prefixes['default'];
        }
        else {

          // When default is not set or an explicit false this means
          // no prefix.
          $ret = '';
        }
      }
    }
  }
  if (empty($ret)) {
    $ret = Redis_Client::getGlobalPrefix();
  }
  return $ret;
}