function queue

Instantiates and statically caches the correct class for a queue.

The following variables can be set by variable_set or $conf overrides:

  • queue_class_$name: The class to be used for the queue $name.
  • queue_default_class: The class to use when queue_class_$name is not defined. Defaults to Drupal\Core\Queue\System, a reliable backend using SQL.
  • queue_default_reliable_class: The class to use when queue_class_$name is not defined and the queue_default_class is not reliable. Defaults to Drupal\Core\Queue\System.

Parameters

string $name: The name of the queue to work with.

bool $reliable: TRUE if the ordering of items and guaranteeing every item executes at least once is important, FALSE if scalability is the main concern. Defaults to FALSE.

Return value

Drupal\Core\Queue\QueueInterface The queue object for a given name.

See also

Drupal\Core\Queue\QueueInterface

Related topics

9 calls to queue()
aggregator_cron in drupal/core/modules/aggregator/aggregator.module
Implements hook_cron().
drupal_cron_run in drupal/core/includes/common.inc
Executes a cron run when called.
hook_cron in drupal/core/modules/system/system.api.php
Perform periodic actions.
UpdateCoreTest::testFetchTasks in drupal/core/modules/update/lib/Drupal/update/Tests/UpdateCoreTest.php
Tests that exactly one fetch task per project is created and not more.
update_fetch_data_batch in drupal/core/modules/update/update.fetch.inc
Batch callback: Processes a step in batch for fetching available update data.

... See full list

File

drupal/core/includes/common.inc, line 6968
Common functions that many Drupal modules will need to reference.

Code

function queue($name, $reliable = FALSE) {
  static $queues;
  if (!isset($queues[$name])) {
    $class = variable_get('queue_class_' . $name, NULL);
    if ($class && $reliable && in_array('Drupal\\Core\\Queue\\ReliableQueueInterface', class_implements($class))) {
      $class = variable_get('queue_default_reliable_class', 'Drupal\\Core\\Queue\\System');
    }
    elseif (!$class) {
      $class = variable_get('queue_default_class', 'Drupal\\Core\\Queue\\System');
    }
    $queues[$name] = new $class($name);
  }
  return $queues[$name];
}