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()

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];
}