function Memory::claimItem

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Queue/Memory.php \Drupal\Core\Queue\Memory::claimItem()
  2. 10 core/lib/Drupal/Core/Queue/Memory.php \Drupal\Core\Queue\Memory::claimItem()
  3. 11.x core/lib/Drupal/Core/Queue/Memory.php \Drupal\Core\Queue\Memory::claimItem()

Overrides QueueInterface::claimItem

1 method overrides Memory::claimItem()
BatchMemory::claimItem in core/lib/Drupal/Core/Queue/BatchMemory.php
Overrides \Drupal\Core\Queue\Memory::claimItem().

File

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

Class

Memory
Static queue implementation.

Namespace

Drupal\Core\Queue

Code

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

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