public function MongoDBQueue::claimItem in MongoDB 7
Claim an item in the queue for processing.
Parameters
int $lease_time: How long the processing is expected to take in seconds.
Return value
object|bool On success we return an item object. If the queue is unable to claim an item it returns false.
Throws
\MongoConnectionException
Overrides DrupalQueueInterface::claimItem
File
- mongodb_queue/
mongodb_queue.inc, line 81 - Contains \MongoDBQueue.
Class
Code
public function claimItem($lease_time = 30) {
$query = array(
'expire' => 0,
);
$newobj = array(
'expire' => time() + $lease_time,
);
$cmd = array(
'findandmodify' => mongodb_collection_name($this->collection),
'query' => $query,
'update' => array(
'$set' => $newobj,
),
'sort' => array(
'created' => 1,
),
);
if (($result = mongodb_collection($this->collection)->db
->command($cmd)) && $result['ok'] == 1 && !empty($result['value'])) {
return (object) $result['value'];
}
}