class MemoryQueue


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
  1. cis7 modules/system/ MemoryQueue
  2. cle7 modules/system/ MemoryQueue
  3. elmsmedia7 modules/system/ MemoryQueue
  4. icor7 modules/system/ MemoryQueue
  5. meedjum_blog7 modules/system/ MemoryQueue
  6. mooc7 modules/system/ MemoryQueue

Static queue implementation.

This allows "undelayed" variants of processes relying on the Queue interface. The queue data resides in memory. It should only be used for items that will be queued and dequeued within a given page request.


Expanded class hierarchy of MemoryQueue


Contains filters are case sensitive
Namesort descending Modifiers Type Description
MemoryQueue::$id_sequence protected property Counter for item ids.
MemoryQueue::$queue protected property The queue data.
MemoryQueue::claimItem public function Claim an item in the queue for processing. Overrides DrupalQueueInterface::claimItem
MemoryQueue::createItem public function Add a queue item and store it directly to the queue. Overrides DrupalQueueInterface::createItem
MemoryQueue::createQueue public function Create a queue. Overrides DrupalQueueInterface::createQueue
MemoryQueue::deleteItem public function Delete a finished item from the queue. Overrides DrupalQueueInterface::deleteItem
MemoryQueue::deleteQueue public function Delete a queue and every item in the queue. Overrides DrupalQueueInterface::deleteQueue
MemoryQueue::numberOfItems public function Retrieve the number of items in the queue. Overrides DrupalQueueInterface::numberOfItems
MemoryQueue::releaseItem public function Release an item that the worker could not process, so another worker can come in and process it before the timeout expires. Overrides DrupalQueueInterface::releaseItem
MemoryQueue::__construct public function Start working with a queue.


modules/system/, line 296
Queue functionality.

View source
class MemoryQueue implements DrupalQueueInterface {
   * The queue data.
   * @var array
  protected $queue;

   * Counter for item ids.
   * @var int
  protected $id_sequence;

   * Start working with a queue.
   * @param $name
   *   Arbitrary string. The name of the queue to work with.
  public function __construct($name) {
    $this->queue = array();
    $this->id_sequence = 0;

  public function createItem($data) {
    $item = new stdClass();
    $item->item_id = $this->id_sequence++;
    $item->data = $data;
    $item->created = time();
    $item->expire = 0;
    $this->queue[$item->item_id] = $item;

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

  public function claimItem($lease_time = 30) {
    foreach ($this->queue as $key => $item) {
      if ($item->expire == 0) {
        $item->expire = time() + $lease_time;
        $this->queue[$key] = $item;
        return $item;
    return FALSE;

  public function deleteItem($item) {

  public function releaseItem($item) {
    if (isset($this->queue[$item->item_id]) && $this->queue[$item->item_id]->expire != 0) {
      $this->queue[$item->item_id]->expire = 0;
      return TRUE;
    return FALSE;

  public function createQueue() {
    // Nothing needed here.

  public function deleteQueue() {
    $this->queue = array();
    $this->id_sequence = 0;

Related topics

1 string reference to 'MemoryQueue'
og-7.x-1.x.database.php in sites/all/modules/ulmus/og/tests/og-7.x-1.x.database.php
Filled installation of Drupal 7.0, for test purposes.