You are here

function get_cache_prefix in File Cache 7

Implement unified cache bin prefix as described in https://www.drupal.org/node/1324812

By default, conf_path() is used as prefix after replacing '/' with '_', and adding final '_'.

@global type $conf

Return value

string The prefix, or empty string if there is no prefix;

2 calls to get_cache_prefix()
DrupalFileCache::__construct in ./filecache.inc
Construct DrupalFileCache for specified cache bin.
filecache_registry_pathname in ./filecache.inc

File

./filecache.inc, line 75
DrupalFileCache class that implements DrupalCacheInterface.

Code

function get_cache_prefix($bin = FALSE) {
  $prefix = str_replace('/', '_', conf_path()) . '_';
  global $conf;
  if (array_key_exists('cache_prefix', $conf)) {
    $cache_prefix_conf = $conf['cache_prefix'];
    if ($cache_prefix_conf === FALSE || is_string($cache_prefix_conf)) {
      $prefix = $cache_prefix_conf;
    }
    elseif (is_array($cache_prefix_conf)) {
      if (is_string($bin) && array_key_exists($bin, $cache_prefix_conf)) {
        $prefix = $cache_prefix_conf[$bin];
      }
      else {
        if (array_key_exists('default', $cache_prefix_conf)) {
          $prefix = $cache_prefix_conf['default'];
        }
      }
    }
  }
  if (is_string($prefix)) {
    return $prefix;
  }
  else {
    return "";
  }
}