function Memory::claimItem

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