class WithoutOverlapping (View source)

Traits

Properties

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.

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(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

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

Get the "available at" UNIX timestamp.

parseDateInterval(DateTimeInterface|DateInterval|int $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 $endTime = null)

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

void
__construct(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.

$this
releaseAfter(DateTimeInterface|int $releaseAfter)

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

$this
dontRelease()

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

$this
expireAfter(DateTimeInterface|DateInterval|int $expiresAfter)

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

$this
withPrefix(string $prefix)

Set the prefix of the lock key.

$this
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

protected int secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

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

Get the "available at" UNIX timestamp.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

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

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

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

DateTimeInterface|int

protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

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

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

Parameters

float $startTime
float $endTime

Return Value

string

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

Create a new middleware instance.

Parameters

string $key
DateTimeInterface|int|null $releaseAfter
DateTimeInterface|int $expiresAfter

Return Value

void

mixed handle(mixed $job, callable $next)

Process the job.

Parameters

mixed $job
callable $next

Return Value

mixed

$this releaseAfter(DateTimeInterface|int $releaseAfter)

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

Parameters

DateTimeInterface|int $releaseAfter

Return Value

$this

$this dontRelease()

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

Return Value

$this

$this expireAfter(DateTimeInterface|DateInterval|int $expiresAfter)

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

Parameters

DateTimeInterface|DateInterval|int $expiresAfter

Return Value

$this

$this withPrefix(string $prefix)

Set the prefix of the lock key.

Parameters

string $prefix

Return Value

$this

$this shared()

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

Return Value

$this

string getLockKey(mixed $job)

Get the lock key for the given job.

Parameters

mixed $job

Return Value

string