Skip to content

Commit

Permalink
Merge pull request #769 from giolvani/patch-1
Browse files Browse the repository at this point in the history
update MongoQueue.php
  • Loading branch information
jenssegers committed Mar 4, 2016
2 parents 9f64e21 + d32f17b commit e1c12ac
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/Jenssegers/Mongodb/Queue/MongoQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,45 @@ protected function releaseJobsThatHaveBeenReservedTooLong($queue)
$this->releaseJob($job['_id'], $attempts);
}
}

/**
* Release the given job ID from reservation.
*
* @param string $id
*
* @return void
*/
protected function releaseJob($id, $attempts)
{
$this->database->table($this->table)->where('_id', $id)->update([
'reserved' => 0,
'reserved_at' => null,
'attempts' => $attempts,
]);
}

/**
* Mark the given job ID as reserved.
*
* @param string $id
* @return void
*/
protected function markJobAsReserved($id)
{
$this->database->collection($this->table)->where('_id', $id)->update([
'reserved' => 1, 'reserved_at' => $this->getTime(),
]);
}

/**
* Delete a reserved job from the queue.
*
* @param string $queue
* @param string $id
* @return void
*/
public function deleteReserved($queue, $id)
{
$this->database->table($this->table)->where('_id', $id)->delete();
}
}

0 comments on commit e1c12ac

Please sign in to comment.