RedisQueue
class RedisQueue extends Queue implements Queue, ClearableQueue
Traits
Properties
| protected Container | $container | The IoC container instance. |
from Queue |
| protected string | $connectionName | The connection name for the queue. |
from Queue |
| protected array | $config | The original configuration for the queue. |
from Queue |
| protected bool | $dispatchAfterCommit | Indicates that jobs should be dispatched after all database transactions have committed. |
from Queue |
| protected null|Queue): mixed): mixed | $afterCommitDispatcher | Dispatch an after-commit operation through its live queue owner. |
from Queue |
| static protected callable[] | $createPayloadCallbacks | The create payload callbacks. |
from Queue |
| protected bool | $secondaryQueueHadJob | Indicates if a secondary queue had a job available between checks of the primary queue. |
|
| protected bool|null | $isCluster | Indicates if the connection is a Redis Cluster connection. |
Methods
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
Get a configuration value from an attribute, falling back to a property.
Extract the value from an attribute instance.
Get an instance of the given attribute class from the target class or its parents.
Determine if a property declared on a child class overrides an inherited attribute.
Push a new job onto the queue.
Push a new job onto a specific queue after (n) seconds.
Push an array of jobs onto the queue.
Create a payload string from the given job and data.
Create a payload string from the given job and data.
Create a payload for an object-based queue handler.
Get the maximum number of attempts for an object-based queue handler.
Get the expiration timestamp for an object-based queue handler.
Create a typical, string based queue payload array.
Register a callback to be executed when creating job payloads.
Create the given payload using any registered payload hooks.
Set the dispatcher for after-commit queue operations.
Enqueue a job using the given callback.
Enqueue a job immediately using the given callback.
Determine if the job should be dispatched after all database transactions have committed.
Register a transaction rollback callback that releases the unique lock for the given job.
Register a transaction rollback callback that releases the debounce token for the given job.
Raise the job queueing event.
Raise the job queued event.
Create a new Redis queue instance.
Get the size of the queue.
Get the number of pending jobs.
Get the number of delayed jobs.
Get the number of reserved jobs.
Get the pending jobs for the given queue.
Get the delayed jobs for the given queue.
Get the reserved jobs for the given queue.
Get all pending jobs across every queue.
Get all delayed jobs across every queue.
Get all reserved jobs across every queue.
Inspect jobs from one queue while holding one Redis connection.
Inspect jobs across every queue while holding one Redis connection.
Inspect one Redis queue using an already-held raw connection.
Get the creation timestamp of the oldest pending job, excluding delayed jobs.
Push a new job onto the queue.
Push a raw payload onto the queue.
Push a new job onto the queue after a delay.
Push a raw job onto the queue after (n) seconds.
Migrate any delayed or expired jobs onto the primary queue.
Migrate the delayed jobs that are ready to the regular queue.
Retrieve the next job from the queue.
Delete a reserved job from the reserved queue and release it.
Delete all of the jobs from the queue.
Get a random ID string.
Get the queue or return the default.
Get the cluster-safe Redis key for the given queue.
Determine if the queue connection is a Redis Cluster connection.
Get the connection for the queue.
Details
in
InteractsWithTime at line 17
protected int
secondsUntil(DateInterval|DateTimeInterface|int $delay)
Get the number of seconds until the given DateTime.
in
InteractsWithTime at line 29
protected int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)
Get the "available at" UNIX timestamp.
in
InteractsWithTime at line 41
protected DateTimeInterface|int
parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)
If the given value is an interval, convert it to a DateTime instance.
in
InteractsWithTime at line 57
protected int
currentTime()
Get the current system time as a UNIX timestamp.
in
InteractsWithTime at line 65
protected string
runTimeForHumans(float $startTime, float|null $endTime = null)
Given a start time, format the total run time for human readability.
in
ReadsClassAttributes at line 15
protected mixed
getAttributeValue(object $target, string $attributeClass, string|null $property = null, mixed $default = null)
Get a configuration value from an attribute, falling back to a property.
in
ReadsClassAttributes at line 44
protected mixed
extractAttributeValue(object $instance)
Extract the value from an attribute instance.
in
ReadsClassAttributes at line 54
protected object|null
getAttributeInstance(object $target, string $attributeClass, ReflectionClass|null $declaringClass = null)
Get an instance of the given attribute class from the target class or its parents.
in
ReadsClassAttributes at line 70
protected bool
propertyOverridesAttribute(object $target, ReflectionClass $reflection, string|null $property, ReflectionClass $attributeDeclaringClass)
Determine if a property declared on a child class overrides an inherited attribute.
in
Queue at line 82
mixed
pushOn(string|null $queue, object|string $job, mixed $data = '')
Push a new job onto the queue.
in
Queue at line 91
mixed
laterOn(string|null $queue, DateInterval|DateTimeInterface|int $delay, object|string $job, mixed $data = '')
Push a new job onto a specific queue after (n) seconds.
at line 246
mixed
bulk(array $jobs, mixed $data = '', string|null $queue = null)
Push an array of jobs onto the queue.
in
Queue at line 117
protected string
createPayload(array|object|string $job, string|null $queue, mixed $data = '', DateInterval|DateTimeInterface|int|null $delay = null)
Create a payload string from the given job and data.
at line 351
protected array
createPayloadArray(array|object|string $job, string|null $queue, mixed $data = '')
Create a payload string from the given job and data.
in
Queue at line 160
protected array
createObjectPayload(object $job, string|null $queue)
Create a payload for an object-based queue handler.
in
Queue at line 214
protected string
getDisplayName(object $job)
Get the display name for the given job.
in
Queue at line 223
mixed
getJobTries(mixed $job)
Get the maximum number of attempts for an object-based queue handler.
in
Queue at line 237
mixed
getJobBackoff(mixed $job)
Get the backoff for an object-based queue handler.
in
Queue at line 257
mixed
getJobExpiration(mixed $job)
Get the expiration timestamp for an object-based queue handler.
in
Queue at line 272
protected bool
jobShouldBeEncrypted(object $job)
Determine if the job should be encrypted.
in
Queue at line 284
protected array
createStringPayload(array|string $job, string|null $queue, mixed $data)
Create a typical, string based queue payload array.
in
Queue at line 307
static void
createPayloadUsing(callable|null $callback)
Register a callback to be executed when creating job payloads.
Boot-only. The callback persists in a static property for the worker lifetime and runs on every subsequent payload creation across all coroutines. Passing null clears the registry.
in
Queue at line 319
protected array
withCreatePayloadHooks(string|null $queue, array $payload)
Create the given payload using any registered payload hooks.
in
Queue at line 335
Queue
setAfterCommitDispatcher(Closure|null $dispatcher)
Set the dispatcher for after-commit queue operations.
in
Queue at line 350
protected mixed
enqueueUsing(object|string $job, string $payload, string|null $queue, DateInterval|DateTimeInterface|int|null $delay, callable $callback)
Enqueue a job using the given callback.
The callback receives the queue that owns the operation first so deferred pooled dispatch never retains a borrowed queue.
in
Queue at line 388
protected mixed
enqueueNow(object|string $job, string $payload, string|null $queue, DateInterval|DateTimeInterface|int|null $delay, callable $callback)
Enqueue a job immediately using the given callback.
in
Queue at line 402
protected bool
shouldDispatchAfterCommit(object|string $job)
Determine if the job should be dispatched after all database transactions have committed.
in
Queue at line 418
protected void
addUniqueJobRollbackCallback(DatabaseTransactionsManager $transactions, object|string $job)
Register a transaction rollback callback that releases the unique lock for the given job.
in
Queue at line 434
protected void
addDebouncedJobRollbackCallback(DatabaseTransactionsManager $transactions, object|string $job)
Register a transaction rollback callback that releases the debounce token for the given job.
in
Queue at line 452
protected void
raiseJobQueueingEvent(string|null $queue, object|string $job, string $payload, DateInterval|DateTimeInterface|int|null $delay)
Raise the job queueing event.
in
Queue at line 473
protected void
raiseJobQueuedEvent(string|null $queue, mixed $jobId, object|string $job, string $payload, DateInterval|DateTimeInterface|int|null $delay)
Raise the job queued event.
in
Queue at line 492
string
getConnectionName()
Get the connection name for the queue.
in
Queue at line 504
Queue
setConnectionName(string $name)
Set the connection name for the queue.
Boot or tests only. Queue connection instances are cached on QueueManager; runtime use races across coroutines and changes every concurrent dispatch through this connection.
in
Queue at line 514
array
getConfig()
Get the queue configuration array.
in
Queue at line 526
Queue
setConfig(array $config)
Set the queue configuration array.
Boot or tests only. Queue connection instances are cached on QueueManager; runtime use races across coroutines and changes every concurrent dispatch through this connection.
in
Queue at line 536
Container
getContainer()
Get the container instance being used by the connection.
in
Queue at line 548
Queue
setContainer(Container $container)
Set the IoC container instance.
Boot or tests only. Queue connection instances are cached on QueueManager; runtime use races across coroutines and changes every concurrent dispatch through this connection.
in
Queue at line 558
static void
flushState()
Flush all static state.
at line 45
__construct(Factory $redis, string $default = 'default', string|null $connection = null, int|null $retryAfter = 60, int|null $blockFor = null, bool $dispatchAfterCommit = false, int $migrationBatchSize = -1)
Create a new Redis queue instance.
at line 59
int
size(string|null $queue = null)
Get the size of the queue.
at line 75
int
pendingSize(string|null $queue = null)
Get the number of pending jobs.
at line 83
int
delayedSize(string|null $queue = null)
Get the number of delayed jobs.
at line 91
int
reservedSize(string|null $queue = null)
Get the number of reserved jobs.
at line 101
Collection
pendingJobs(string|null $queue = null)
Get the pending jobs for the given queue.
at line 111
Collection
delayedJobs(string|null $queue = null)
Get the delayed jobs for the given queue.
at line 121
Collection
reservedJobs(string|null $queue = null)
Get the reserved jobs for the given queue.
at line 131
Collection
allPendingJobs()
Get all pending jobs across every queue.
at line 141
Collection
allDelayedJobs()
Get all delayed jobs across every queue.
at line 151
Collection
allReservedJobs()
Get all reserved jobs across every queue.
at line 161
protected Collection
inspectJobs(string|null $queue, string $suffix = '')
Inspect jobs from one queue while holding one Redis connection.
at line 180
protected Collection
inspectAllQueues(string $suffix = '')
Inspect jobs across every queue while holding one Redis connection.
at line 216
protected Collection
inspectJobsUsing(RedisConnection $connection, string $name, string $suffix)
Inspect one Redis queue using an already-held raw connection.
at line 230
int|null
creationTimeOfOldestPendingJob(string|null $queue = null)
Get the creation timestamp of the oldest pending job, excluding delayed jobs.
at line 278
mixed
push(object|string $job, mixed $data = '', string|null $queue = null)
Push a new job onto the queue.
at line 294
mixed
pushRaw(string $payload, string|null $queue = null, array $options = [])
Push a raw payload onto the queue.
at line 312
mixed
later(DateInterval|DateTimeInterface|int $delay, object|string $job, mixed $data = '', string|null $queue = null)
Push a new job onto the queue after a delay.
at line 333
protected mixed
laterRaw(DateInterval|DateTimeInterface|int $delay, string $payload, string|null $queue = null)
Push a raw job onto the queue after (n) seconds.
at line 362
Job|null
pop(string|null $queue = null, int $index = 0)
Pop the next job off of the queue.
at line 396
protected void
migrate(string $queue)
Migrate any delayed or expired jobs onto the primary queue.
at line 408
array
migrateExpiredJobs(string $from, string $to)
Migrate the delayed jobs that are ready to the regular queue.
at line 426
protected array
retrieveNextJob(string $queue, bool $block = true)
Retrieve the next job from the queue.
at line 455
void
deleteReserved(string $queue, RedisJob $job)
Delete a reserved job from the queue.
at line 463
void
deleteAndRelease(string $queue, RedisJob $job, DateInterval|DateTimeInterface|int $delay)
Delete a reserved job from the reserved queue and release it.
at line 480
int
clear(string|null $queue)
Delete all of the jobs from the queue.
at line 498
protected string
getRandomId()
Get a random ID string.
at line 506
string
getQueue(string|null $queue)
Get the queue or return the default.
at line 518
protected string
getQueueRedisKey(string|null $queue = null)
Get the cluster-safe Redis key for the given queue.
Redis Cluster requires every key passed to a multi-key Lua script to live on the same hash slot. Queue payloads keep the logical queue name via getQueue(); only storage keys are hash-tagged here.
at line 530
protected bool
isClusterConnection()
Determine if the queue connection is a Redis Cluster connection.
at line 538
RedisProxy
getConnection()
Get the connection for the queue.
at line 546
Factory
getRedis()
Get the underlying Redis instance.