DatabaseQueue

class DatabaseQueue extends Queue implements Queue (View source)

Properties

protected Container $container The IoC container instance. from Queue
protected Connection $database The database connection instance.
protected string $table The database table that holds the jobs.
protected string $default The name of the default queue.
protected int|null $expire The expiration time of a job.

Methods

mixed pushOn(string $queue, string $job, mixed $data = '')

Push a new job onto the queue.

from Queue
mixed laterOn(string $queue, DateTime|int $delay, string $job, mixed $data = '')

Push a new job onto the queue after a delay.

from Queue
marshal() deprecated

Marshal a push queue request and fire the job.

from Queue
mixed bulk(array $jobs, mixed $data = '', string $queue = null)

Push an array of jobs onto the queue.

string createPayload(string $job, mixed $data = '', string $queue = null)

Create a payload string from the given job and data.

from Queue
array createPlainPayload(string $job, mixed $data)

Create a typical, "plain" queue payload array.

from Queue
mixed prepareQueueableEntities(mixed $data)

Prepare any queueable entities for storage in the queue.

from Queue
mixed prepareQueueableEntity(mixed $value)

Prepare a single queueable entity for storage on the queue.

from Queue
string createClosurePayload(Closure $job, mixed $data)

Create a payload string for the given Closure job.

from Queue
string setMeta(string $payload, string $key, string $value)

Set additional meta on a payload string.

from Queue
int getSeconds(DateTime|int $delay)

Calculate the number of seconds with the given delay.

from Queue
int getTime()

Get the current UNIX timestamp.

from Queue
void setContainer(Container $container)

Set the IoC container instance.

from Queue
void setEncrypter(Encrypter $crypt)

Set the encrypter instance.

from Queue
void __construct(Connection $database, string $table, string $default = 'default', int $expire = 60)

Create a new database queue instance.

mixed push(string $job, mixed $data = '', string $queue = null)

Push a new job onto the queue.

mixed pushRaw(string $payload, string $queue = null, array $options = [])

Push a raw payload onto the queue.

mixed later(DateTime|int $delay, string $job, mixed $data = '', string $queue = null)

Push a new job onto the queue after a delay.

mixed release(string $queue, StdClass $job, int $delay)

Release a reserved job back onto the queue.

mixed pushToDatabase(DateTime|int $delay, string|null $queue, string $payload, int $attempts)

Push a raw payload to the database with a given delay.

Job|null pop(string $queue = null)

Pop the next job off of the queue.

void releaseJobsThatHaveBeenReservedTooLong(string $queue)

Release the jobs that have been reserved for too long.

StdClass|null getNextAvailableJob(string|null $queue)

Get the next available job for the queue.

void markJobAsReserved(string $id)

Mark the given job ID as reserved.

void deleteReserved(string $queue, string $id)

Delete a reserved job from the queue.

int getAvailableAt(DateTime|int $delay)

Get the "available at" UNIX timestamp.

array buildDatabaseRecord(string|null $queue, string $payload, int $availableAt, int $attempts)

Create an array to insert for the given job.

string getQueue(string|null $queue)

Get the queue or return the default.

Connection getDatabase()

Get the underlying database instance.

int|null getExpire()

Get the expiration time in seconds.

void setExpire(int|null $seconds)

Set the expiration time in seconds.

Details

mixed pushOn(string $queue, string $job, mixed $data = '')

Push a new job onto the queue.

Parameters

string $queue
string $job
mixed $data

Return Value

mixed

mixed laterOn(string $queue, DateTime|int $delay, string $job, mixed $data = '')

Push a new job onto the queue after a delay.

Parameters

string $queue
DateTime|int $delay
string $job
mixed $data

Return Value

mixed

marshal() deprecated

deprecated

since version 5.1.

Marshal a push queue request and fire the job.

Exceptions

RuntimeException

mixed bulk(array $jobs, mixed $data = '', string $queue = null)

Push an array of jobs onto the queue.

Parameters

array $jobs
mixed $data
string $queue

Return Value

mixed

protected string createPayload(string $job, mixed $data = '', string $queue = null)

Create a payload string from the given job and data.

Parameters

string $job
mixed $data
string $queue

Return Value

string

protected array createPlainPayload(string $job, mixed $data)

Create a typical, "plain" queue payload array.

Parameters

string $job
mixed $data

Return Value

array

protected mixed prepareQueueableEntities(mixed $data)

Prepare any queueable entities for storage in the queue.

Parameters

mixed $data

Return Value

mixed

protected mixed prepareQueueableEntity(mixed $value)

Prepare a single queueable entity for storage on the queue.

Parameters

mixed $value

Return Value

mixed

protected string createClosurePayload(Closure $job, mixed $data)

Create a payload string for the given Closure job.

Parameters

Closure $job
mixed $data

Return Value

string

protected string setMeta(string $payload, string $key, string $value)

Set additional meta on a payload string.

Parameters

string $payload
string $key
string $value

Return Value

string

protected int getSeconds(DateTime|int $delay)

Calculate the number of seconds with the given delay.

Parameters

DateTime|int $delay

Return Value

int

protected int getTime()

Get the current UNIX timestamp.

Return Value

int

void setContainer(Container $container)

Set the IoC container instance.

Parameters

Container $container

Return Value

void

void setEncrypter(Encrypter $crypt)

Set the encrypter instance.

Parameters

Encrypter $crypt

Return Value

void

void __construct(Connection $database, string $table, string $default = 'default', int $expire = 60)

Create a new database queue instance.

Parameters

Connection $database
string $table
string $default
int $expire

Return Value

void

mixed push(string $job, mixed $data = '', string $queue = null)

Push a new job onto the queue.

Parameters

string $job
mixed $data
string $queue

Return Value

mixed

mixed pushRaw(string $payload, string $queue = null, array $options = [])

Push a raw payload onto the queue.

Parameters

string $payload
string $queue
array $options

Return Value

mixed

mixed later(DateTime|int $delay, string $job, mixed $data = '', string $queue = null)

Push a new job onto the queue after a delay.

Parameters

DateTime|int $delay
string $job
mixed $data
string $queue

Return Value

mixed

mixed release(string $queue, StdClass $job, int $delay)

Release a reserved job back onto the queue.

Parameters

string $queue
StdClass $job
int $delay

Return Value

mixed

protected mixed pushToDatabase(DateTime|int $delay, string|null $queue, string $payload, int $attempts)

Push a raw payload to the database with a given delay.

Parameters

DateTime|int $delay
string|null $queue
string $payload
int $attempts

Return Value

mixed

Job|null pop(string $queue = null)

Pop the next job off of the queue.

Parameters

string $queue

Return Value

Job|null

protected void releaseJobsThatHaveBeenReservedTooLong(string $queue)

Release the jobs that have been reserved for too long.

Parameters

string $queue

Return Value

void

protected StdClass|null getNextAvailableJob(string|null $queue)

Get the next available job for the queue.

Parameters

string|null $queue

Return Value

StdClass|null

protected void markJobAsReserved(string $id)

Mark the given job ID as reserved.

Parameters

string $id

Return Value

void

void deleteReserved(string $queue, string $id)

Delete a reserved job from the queue.

Parameters

string $queue
string $id

Return Value

void

protected int getAvailableAt(DateTime|int $delay)

Get the "available at" UNIX timestamp.

Parameters

DateTime|int $delay

Return Value

int

protected array buildDatabaseRecord(string|null $queue, string $payload, int $availableAt, int $attempts)

Create an array to insert for the given job.

Parameters

string|null $queue
string $payload
int $availableAt
int $attempts

Return Value

array

protected string getQueue(string|null $queue)

Get the queue or return the default.

Parameters

string|null $queue

Return Value

string

Connection getDatabase()

Get the underlying database instance.

Return Value

Connection

int|null getExpire()

Get the expiration time in seconds.

Return Value

int|null

void setExpire(int|null $seconds)

Set the expiration time in seconds.

Parameters

int|null $seconds

Return Value

void

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.1/Illuminate/Queue/DatabaseQueue.html