You are here

abstract class QueueBase in Redis 8

Redis queue implementation.

Hierarchy

Expanded class hierarchy of QueueBase

File

src/Queue/QueueBase.php, line 12

Namespace

Drupal\redis\Queue
View source
abstract class QueueBase implements QueueInterface {

  /**
   * Prefix used with all keys.
   */
  const KEY_PREFIX = 'drupal:queue:';

  /**
   * The name of the queue this instance is working with.
   *
   * @var string
   */
  protected $name;

  /**
   * Key for list of available items.
   *
   * @var string
   */
  protected $availableListKey;

  /**
   * Key for list of claimed items.
   *
   * @var string
   */
  protected $claimedListKey;

  /**
   * Key prefix for items that are used to track expiration of leased items.
   *
   * @var string
   */
  protected $leasedKeyPrefix;

  /**
   * Key of increment counter key.
   *
   * @var string
   */
  protected $incrementCounterKey;

  /**
   * Key for hash table of available queue items.
   *
   * @var string
   */
  protected $availableItems;

  /**
   * Reserve timeout for blocking item claim.
   *
   * This will be set to number of seconds to wait for an item to be claimed.
   * Non-blocking approach will be used when set to NULL.
   *
   * @var int|null
   */
  protected $reserveTimeout;

  /**
   * Constructs a \Drupal\Core\Queue\DatabaseQueue object.
   *
   * @param string $name
   *   The name of the queue.
   * @param array $settings
   *   Array of Redis-related settings for this queue.
   */
  public function __construct($name, array $settings) {
    $this->name = $name;
    $this->reserveTimeout = $settings['reserve_timeout'];
    $this->availableListKey = static::KEY_PREFIX . $name . ':avail';
    $this->availableItems = static::KEY_PREFIX . $name . ':items';
    $this->claimedListKey = static::KEY_PREFIX . $name . ':claimed';
    $this->leasedKeyPrefix = static::KEY_PREFIX . $name . ':lease:';
    $this->incrementCounterKey = static::KEY_PREFIX . $name . ':counter';
  }

  /**
   * {@inheritdoc}
   */
  public function createQueue() {

    // Nothing to do here.
  }

}

Members

Namesort descending Modifiers Type Description Overrides
QueueBase::$availableItems protected property Key for hash table of available queue items.
QueueBase::$availableListKey protected property Key for list of available items.
QueueBase::$claimedListKey protected property Key for list of claimed items.
QueueBase::$incrementCounterKey protected property Key of increment counter key.
QueueBase::$leasedKeyPrefix protected property Key prefix for items that are used to track expiration of leased items.
QueueBase::$name protected property The name of the queue this instance is working with.
QueueBase::$reserveTimeout protected property Reserve timeout for blocking item claim.
QueueBase::createQueue public function Creates a queue. Overrides QueueInterface::createQueue
QueueBase::KEY_PREFIX constant Prefix used with all keys.
QueueBase::__construct public function Constructs a \Drupal\Core\Queue\DatabaseQueue object. 4
QueueInterface::claimItem public function Claims an item in the queue for processing. 2
QueueInterface::createItem public function Adds a queue item and store it directly to the queue. 2
QueueInterface::deleteItem public function Deletes a finished item from the queue. 2
QueueInterface::deleteQueue public function Deletes a queue and every item in the queue. 2
QueueInterface::numberOfItems public function Retrieves the number of items in the queue. 2
QueueInterface::releaseItem public function Releases an item that the worker could not process. 2