IQueue
in
Queue interface for managing job queues.
This interface defines the contract for different queue drivers (database, file, Redis, etc.) to implement job queue functionality.
Table of Contents
Methods
- clear() : int
- Clear all jobs from the queue
- clearFailedJobs() : int
- Clear all failed jobs
- delete() : void
- Delete a job from the queue Called when a job completes successfully
- failed() : void
- Mark a job as failed Moves the job to failed jobs storage
- forgetFailedJob() : bool
- Delete a failed job
- getFailedJobs() : array<string|int, mixed>
- Get all failed jobs
- pop() : QueuedJob|null
- Pop the next available job from the queue
- push() : string
- Push a job onto the queue
- release() : void
- Release a job back to the queue Used when a job fails and should be retried
- retryFailedJob() : bool
- Retry a failed job
- size() : int
- Get the size of the queue
Methods
clear()
Clear all jobs from the queue
public
clear([string $queue = 'default' ]) : int
Parameters
- $queue : string = 'default'
-
Queue name (default: 'default')
Return values
int —Number of jobs cleared
clearFailedJobs()
Clear all failed jobs
public
clearFailedJobs() : int
Return values
int —Number of failed jobs cleared
delete()
Delete a job from the queue Called when a job completes successfully
public
delete(QueuedJob $job) : void
Parameters
- $job : QueuedJob
-
Job to delete
failed()
Mark a job as failed Moves the job to failed jobs storage
public
failed(QueuedJob $job, Throwable $exception) : void
Parameters
- $job : QueuedJob
-
Failed job
- $exception : Throwable
-
Exception that caused the failure
forgetFailedJob()
Delete a failed job
public
forgetFailedJob(string $id) : bool
Parameters
- $id : string
-
Failed job ID
Return values
bool —True if job was deleted, false if not found
getFailedJobs()
Get all failed jobs
public
getFailedJobs() : array<string|int, mixed>
Return values
array<string|int, mixed> —Array of failed job data
pop()
Pop the next available job from the queue
public
pop([string $queue = 'default' ]) : QueuedJob|null
Parameters
- $queue : string = 'default'
-
Queue name (default: 'default')
Return values
QueuedJob|null —The next job, or null if queue is empty
push()
Push a job onto the queue
public
push(IJob $job[, array<string|int, mixed> $args = [] ][, string $queue = 'default' ][, int $delay = 0 ]) : string
Parameters
- $job : IJob
-
Job instance to queue
- $args : array<string|int, mixed> = []
-
Arguments to pass to the job
- $queue : string = 'default'
-
Queue name (default: 'default')
- $delay : int = 0
-
Delay in seconds before the job is available
Return values
string —Job ID
release()
Release a job back to the queue Used when a job fails and should be retried
public
release(QueuedJob $job[, int $delay = 0 ]) : void
Parameters
- $job : QueuedJob
-
Job to release
- $delay : int = 0
-
Delay in seconds before job is available again
retryFailedJob()
Retry a failed job
public
retryFailedJob(string $id) : bool
Parameters
- $id : string
-
Failed job ID
Return values
bool —True if job was retried, false if not found
size()
Get the size of the queue
public
size([string $queue = 'default' ]) : int
Parameters
- $queue : string = 'default'
-
Queue name (default: 'default')
Return values
int —Number of jobs in the queue