You are here

class QueueManager in Warmer 2.x

Same name and namespace in other branches
  1. 8 src/QueueManager.php \Drupal\warmer\QueueManager

Manage queue items and processing.

Hierarchy

Expanded class hierarchy of QueueManager

1 file declares its use of QueueManager
WarmerCommands.php in src/Commands/WarmerCommands.php
1 string reference to 'QueueManager'
warmer.services.yml in ./warmer.services.yml
warmer.services.yml
1 service uses QueueManager
warmer.queue_manager in ./warmer.services.yml
Drupal\warmer\QueueManager

File

src/QueueManager.php, line 11

Namespace

Drupal\warmer
View source
class QueueManager {
  const QUEUE_NAME = 'warmer';

  /**
   * The queue.
   *
   * @var \Drupal\Core\Queue\QueueInterface
   */
  private $queue;

  /**
   * Sets the queue to use to execute the cache warming operations.
   *
   * @param \Drupal\Core\Queue\QueueFactory
   *   The queue factory.
   * @param bool $is_reliable
   *   Indicates if the queue should be reliable.
   */
  public function setQueue(QueueFactory $queue_factory, $is_reliable) {
    $queue_factory
      ->get(static::QUEUE_NAME, $is_reliable)
      ->createQueue();
    $this->queue = $queue_factory
      ->get(static::QUEUE_NAME, $is_reliable);
  }

  /**
   * Add a batch of warming operations to the queue.
   *
   * @param callable $callback
   *   The operation to call when dequeuing.
   * @param array $ids
   *   The list of IDs.
   * @param \Drupal\warmer\Plugin\WarmerPluginBase $warmer
   *   The warmer plugin.
   */
  public function enqueueBatch(callable $callback, array $ids, WarmerPluginBase $warmer) {
    $this->queue
      ->createItem(new QueueData($callback, $ids, $warmer
      ->getPluginId()));
    $warmer
      ->markAsEnqueued();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
QueueManager::$queue private property The queue.
QueueManager::enqueueBatch public function Add a batch of warming operations to the queue.
QueueManager::QUEUE_NAME constant
QueueManager::setQueue public function Sets the queue to use to execute the cache warming operations.