class UniqueLock

Traits

Methods

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.

mixed
extractAttributeValue(object $instance)

Extract the value from an attribute instance.

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.

bool
propertyOverridesAttribute(object $target, ReflectionClass $reflection, string|null $property, ReflectionClass $attributeDeclaringClass)

Determine if a property declared on a child class overrides an inherited attribute.

__construct(Repository $cache)

Create a new unique lock manager instance.

bool
acquire(mixed $job)

Attempt to acquire a lock for the given job.

bool
acquireForDispatch(object $job)

Attempt to acquire and register a lock owned by a dispatch operation.

array
resolveLockValues(mixed $job)

Resolve the values needed to acquire a unique lock.

false|string
acquireResolvedLock(mixed $job, Repository $cache, string $key, int $uniqueFor, bool $supportsOwnership, bool $captureOwner = false)

Acquire a unique lock using resolved values.

void
release(mixed $job, string $owner = '')

Release the lock for the given job.

static void
releaseOwned(Repository $cache, string $key, string $owner = '')

Release a unique lock from already-resolved provenance.

static string
getKey(mixed $job)

Generate the lock key for the given job.

Details

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.

Parameters

object $target
string $attributeClass
string|null $property
mixed $default

Return Value

mixed

protected mixed extractAttributeValue(object $instance)

Extract the value from an attribute instance.

Parameters

object $instance

Return Value

mixed

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.

Parameters

object $target
string $attributeClass
ReflectionClass|null $declaringClass

Return Value

object|null

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.

Parameters

object $target
ReflectionClass $reflection
string|null $property
ReflectionClass $attributeDeclaringClass

Return Value

bool

at line 20
__construct(Repository $cache)

Create a new unique lock manager instance.

Parameters

Repository $cache

at line 28
bool acquire(mixed $job)

Attempt to acquire a lock for the given job.

Parameters

mixed $job

Return Value

bool

at line 44
bool acquireForDispatch(object $job)

Attempt to acquire and register a lock owned by a dispatch operation.

Parameters

object $job

Return Value

bool

at line 72
protected array resolveLockValues(mixed $job)

Resolve the values needed to acquire a unique lock.

Parameters

mixed $job

Return Value

array

at line 95
protected false|string acquireResolvedLock(mixed $job, Repository $cache, string $key, int $uniqueFor, bool $supportsOwnership, bool $captureOwner = false)

Acquire a unique lock using resolved values.

Parameters

mixed $job
Repository $cache
string $key
int $uniqueFor
bool $supportsOwnership
bool $captureOwner

Return Value

false|string

false when the lock was not acquired, otherwise its owner or an empty string when no owner was captured

at line 128
void release(mixed $job, string $owner = '')

Release the lock for the given job.

Parameters

mixed $job
string $owner

the captured lock owner for a job without Queueable state

Return Value

void

at line 146
static void releaseOwned(Repository $cache, string $key, string $owner = '')

internal  
 

Release a unique lock from already-resolved provenance.

Parameters

Repository $cache
string $key
string $owner

Return Value

void

at line 164
static string getKey(mixed $job)

Generate the lock key for the given job.

Parameters

mixed $job

Return Value

string