function Memory::numberOfItems

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Queue/Memory.php \Drupal\Core\Queue\Memory::numberOfItems()
  2. 8.9.x core/lib/Drupal/Core/Queue/Memory.php \Drupal\Core\Queue\Memory::numberOfItems()
  3. 11.x core/lib/Drupal/Core/Queue/Memory.php \Drupal\Core\Queue\Memory::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

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

Overrides QueueInterface::numberOfItems

File

core/lib/Drupal/Core/Queue/Memory.php, line 57

Class

Memory
Static queue implementation.

Namespace

Drupal\Core\Queue

Code

public function numberOfItems() {
    return count($this->queue);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.