Skip to content

Commit d32f17b

Browse files
committed
update MongoQueue.php
Some fixes to delete successfully processed jobs on queues.
1 parent 9f64e21 commit d32f17b

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/Jenssegers/Mongodb/Queue/MongoQueue.php

+41
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,45 @@ protected function releaseJobsThatHaveBeenReservedTooLong($queue)
4949
$this->releaseJob($job['_id'], $attempts);
5050
}
5151
}
52+
53+
/**
54+
* Release the given job ID from reservation.
55+
*
56+
* @param string $id
57+
*
58+
* @return void
59+
*/
60+
protected function releaseJob($id, $attempts)
61+
{
62+
$this->database->table($this->table)->where('_id', $id)->update([
63+
'reserved' => 0,
64+
'reserved_at' => null,
65+
'attempts' => $attempts,
66+
]);
67+
}
68+
69+
/**
70+
* Mark the given job ID as reserved.
71+
*
72+
* @param string $id
73+
* @return void
74+
*/
75+
protected function markJobAsReserved($id)
76+
{
77+
$this->database->collection($this->table)->where('_id', $id)->update([
78+
'reserved' => 1, 'reserved_at' => $this->getTime(),
79+
]);
80+
}
81+
82+
/**
83+
* Delete a reserved job from the queue.
84+
*
85+
* @param string $queue
86+
* @param string $id
87+
* @return void
88+
*/
89+
public function deleteReserved($queue, $id)
90+
{
91+
$this->database->table($this->table)->where('_id', $id)->delete();
92+
}
5293
}

0 commit comments

Comments
 (0)