You are here

public function DatabaseQueue::numberOfItems in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Queue/DatabaseQueue.php \Drupal\Core\Queue\DatabaseQueue::numberOfItems()

Retrieves the number of items in the queue.

This is intended to provide a "best guess" count of the number of items in the queue. Depending on the implementation and the setup, the accuracy of the results of this function may vary.

e.g. On a busy system with a large number of consumers and items, the result might only be valid for a fraction of a second and not provide an accurate representation.

Return value

An integer estimate of the number of items in the queue.

Overrides QueueInterface::numberOfItems

File

core/lib/Drupal/Core/Queue/DatabaseQueue.php, line 68
Contains \Drupal\Core\Queue\DatabaseQueue.

Class

DatabaseQueue
Default queue implementation.

Namespace

Drupal\Core\Queue

Code

public function numberOfItems() {
  return $this->connection
    ->query('SELECT COUNT(item_id) FROM {queue} WHERE name = :name', array(
    ':name' => $this->name,
  ))
    ->fetchField();
}