class WithoutOverlapping

Traits

Properties

string $key

The job's unique key used for preventing overlaps.

int $expiresAfter

The number of seconds before the lock should expire.

string $prefix

The prefix of the lock key.

bool $shareKey

Share the key across different jobs.

Methods

int
secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)

If the given value is an interval, convert it to a DateTime instance.

int
currentTime()

Get the current system time as a UNIX timestamp.

string
runTimeForHumans(float $startTime, float|null $endTime = null)

Given a start time, format the total run time for human readability.

__construct(UnitEnum|string $key = '', DateTimeInterface|int|null $releaseAfter = 0, DateTimeInterface|int $expiresAfter = 0)

Create a new middleware instance.

mixed
handle(mixed $job, callable $next)

Process the job.

releaseAfter(DateTimeInterface|int $releaseAfter)

Set the delay (in seconds) to release the job back to the queue.

dontRelease()

Do not release the job back to the queue if no lock can be acquired.

expireAfter(DateInterval|DateTimeInterface|int $expiresAfter)

Set the maximum number of seconds that can elapse before the lock is released.

withPrefix(string $prefix)

Set the prefix of the lock key.

shared()

Indicate that the lock key should be shared across job classes.

string
getLockKey(mixed $job)

Get the lock key for the given job.

Details

in InteractsWithTime at line 17
protected int secondsUntil(DateInterval|DateTimeInterface|int $delay)

Get the number of seconds until the given DateTime.

Parameters

DateInterval|DateTimeInterface|int $delay

Return Value

int

in InteractsWithTime at line 29
protected int availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)

Get the "available at" UNIX timestamp.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

int

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.

Parameters

DateInterval|DateTimeInterface|int|null $delay

Return Value

DateTimeInterface|int

in InteractsWithTime at line 57
protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

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.

Parameters

float $startTime
float|null $endTime

Return Value

string

at line 49
__construct(UnitEnum|string $key = '', DateTimeInterface|int|null $releaseAfter = 0, DateTimeInterface|int $expiresAfter = 0)

Create a new middleware instance.

Parameters

UnitEnum|string $key

the job's unique key used for preventing overlaps

DateTimeInterface|int|null $releaseAfter

the number of seconds before a job should be available again if no lock was acquired

DateTimeInterface|int $expiresAfter

the number of seconds before the lock should expire

at line 61
mixed handle(mixed $job, callable $next)

Process the job.

Parameters

mixed $job
callable $next

Return Value

mixed

at line 88
WithoutOverlapping releaseAfter(DateTimeInterface|int $releaseAfter)

Set the delay (in seconds) to release the job back to the queue.

Parameters

DateTimeInterface|int $releaseAfter

Return Value

WithoutOverlapping

at line 98
WithoutOverlapping dontRelease()

Do not release the job back to the queue if no lock can be acquired.

Return Value

WithoutOverlapping

at line 108
WithoutOverlapping expireAfter(DateInterval|DateTimeInterface|int $expiresAfter)

Set the maximum number of seconds that can elapse before the lock is released.

Parameters

DateInterval|DateTimeInterface|int $expiresAfter

Return Value

WithoutOverlapping

at line 118
WithoutOverlapping withPrefix(string $prefix)

Set the prefix of the lock key.

Parameters

string $prefix

Return Value

WithoutOverlapping

at line 128
WithoutOverlapping shared()

Indicate that the lock key should be shared across job classes.

Return Value

WithoutOverlapping

at line 138
string getLockKey(mixed $job)

Get the lock key for the given job.

Parameters

mixed $job

Return Value

string