/**
  * Get site default global prefix
  *
  * @return string
  */
 public static function getGlobalPrefix()
 {
     // Provide a fallback for multisite. This is on purpose not inside the
     // getPrefixForBin() function in order to decouple the unified prefix
     // variable logic and custom module related security logic, that is not
     // necessary for all backends. We can't just use HTTP_HOST, as multiple
     // hosts might be using the same database. Or, more commonly, a site
     // might not be a multisite at all, but might be using Drush leading to
     // a separate HTTP_HOST of 'default'. Likewise, we can't rely on
     // conf_path(), as settings.php might be modifying what database to
     // connect to. To mirror what core does with database caching we use
     // the DB credentials to inform our cache key.
     if (null === self::$globalPrefix) {
         if (isset($GLOBALS['db_url'])) {
             // Drupal 6 specifics when using the cache_backport module, we
             // therefore cannot use \Database class to determine database
             // settings.
             self::$globalPrefix = md5($GLOBALS['db_url']);
         } else {
             require_once DRUPAL_ROOT . '/includes/database/database.inc';
             $dbInfo = Database::getConnectionInfo();
             $active = $dbInfo['default'];
             self::$globalPrefix = md5($active['host'] . $active['database'] . $active['prefix']['default']);
         }
     }
     return self::$globalPrefix;
 }
Exemple #2
0
 /**
  * Generate a redis key name for the current lock name
  */
 public function getKey($name = null)
 {
     if (null === $name) {
         return parent::getKey('lock');
     } else {
         return parent::getKey(array('lock', $name));
     }
 }
Exemple #3
0
 public function __construct($namespace)
 {
     parent::__construct($namespace);
     $className = Redis_Client::getClass(Redis_Client::REDIS_IMPL_CACHE);
     $this->backend = new $className($this->getKey());
     $this->refreshClearMode();
     $this->refreshPermTtl();
     $this->refreshMaxTtl();
 }
Exemple #4
0
 public function getKey($cid = null)
 {
     if (null === $cid) {
         return parent::getKey($this->bin);
     } else {
         return parent::getKey($this->bin . ':' . $cid);
     }
 }
Exemple #5
0
 /**
  * Default contructor
  *
  * Beware that DrupalQueueInterface does not defines the __construct
  * method in the interface yet is being used from DrupalQueue::get()
  *
  * @param mixed $client
  * @param string $name
  */
 public function __construct($client, $name)
 {
     parent::__construct($client, self::QUEUE_KEY_PREFIX . $name);
 }