Beispiel #1
0
 public function __construct($bin)
 {
     parent::__construct($bin);
     $this->bin = $bin;
     // Check if the server can use EVAL
     if (variable_get('redis_eval_enabled', false)) {
         $this->useEval = true;
     }
     if (null !== ($mode = variable_get('redis_flush_mode_' . $this->bin, null))) {
         // A bin specific flush mode has been set.
         $this->clearMode = (int) $mode;
     } else {
         if (null !== ($mode = variable_get('redis_flush_mode', null))) {
             // A site wide generic flush mode has been set.
             $this->clearMode = (int) $mode;
         } else {
             // No flush mode is set by configuration: provide sensible defaults.
             // See FLUSH_* constants for comprehensible explaination of why this
             // exists.
             switch ($this->bin) {
                 case 'cache_page':
                 case 'cache_block':
                     $this->clearMode = self::FLUSH_TEMPORARY;
                     break;
                 default:
                     $this->clearMode = self::FLUSH_NOTHING;
                     break;
             }
         }
     }
     $ttl = null;
     if (null === ($ttl = variable_get('redis_perm_ttl_' . $this->bin, null))) {
         if (null === ($ttl = variable_get('redis_perm_ttl', null))) {
             $ttl = self::LIFETIME_PERM_DEFAULT;
         }
     }
     if ($ttl === (int) $ttl) {
         $this->permTtl = $ttl;
     } else {
         if ($iv = DateInterval::createFromDateString($ttl)) {
             // http://stackoverflow.com/questions/14277611/convert-dateinterval-object-to-seconds-in-php
             $this->permTtl = $iv->y * 31536000 + $iv->m * 2592000 + $iv->days * 86400 + $iv->h * 3600 + $iv->i * 60 + $iv->s;
         } else {
             // Sorry but we have to log this somehow.
             trigger_error(sprintf("Parsed TTL '%s' has an invalid value: switching to default", $ttl));
             $this->permTtl = self::LIFETIME_PERM_DEFAULT;
         }
     }
 }
Beispiel #2
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();
 }
Beispiel #3
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);
 }