You are here

public static function Redis_AbstractBackend::getDefaultPrefix in Redis 7.2

Get global default prefix

Parameters

string $namespace:

Return value

string

1 call to Redis_AbstractBackend::getDefaultPrefix()
Redis_AbstractBackend::__construct in lib/Redis/AbstractBackend.php
Default constructor

File

lib/Redis/AbstractBackend.php, line 56

Class

Redis_AbstractBackend

Code

public static function getDefaultPrefix($namespace = null) {
  $ret = null;
  if (isset($GLOBALS['drupal_test_info']) && !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 = self::getGlobalPrefix();
  }
  return $ret;
}