class DebounceLock (View source)

Traits

Properties

protected Repository $cache

The cache repository implementation.

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)

Get an instance of the given attribute class from the target class or its parents.

__construct(Repository $cache)

Create a new debounce lock manager instance.

acquire(mixed $job, int|null $debounceFor = null, int|null $maxWait = null)

Store a debounce owner token for the given job.

bool
maxWaitExceeded(Repository $cache, string $key, int $ttl, int|null $maxWait)

Determine if the maximum debounce wait time has been exceeded.

bool
isCurrentOwner(mixed $job, string $owner)

Determine if the given owner is the current owner for this debounce key.

bool
lockExists(mixed $job)

Determine if a debounce token exists for the given job.

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

Remove the debounce token for the given job.

int|null
getDebounceDelay(mixed $job)

Get the debounce delay for the given job.

int|null
getMaxDebounceWait(mixed $job)

Get the maximum debounce wait time for the given job.

static string
getKey(mixed $job)

Generate the cache key for the given job.

resolveCache(mixed $job)

Resolve the cache store 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)

Get an instance of the given attribute class from the target class or its parents.

Parameters

object $target
string $attributeClass

Return Value

object|null

__construct(Repository $cache)

Create a new debounce lock manager instance.

Parameters

Repository $cache

acquire(mixed $job, int|null $debounceFor = null, int|null $maxWait = null)

Store a debounce owner token for the given job.

Overwrites any existing token, implementing last-writer-wins semantics.

Parameters

mixed $job
int|null $debounceFor
int|null $maxWait

protected bool maxWaitExceeded(Repository $cache, string $key, int $ttl, int|null $maxWait)

Determine if the maximum debounce wait time has been exceeded.

Parameters

Repository $cache
string $key
int $ttl
int|null $maxWait

Return Value

bool

bool isCurrentOwner(mixed $job, string $owner)

Determine if the given owner is the current owner for this debounce key.

Parameters

mixed $job
string $owner

Return Value

bool

bool lockExists(mixed $job)

Determine if a debounce token exists for the given job.

Parameters

mixed $job

Return Value

bool

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

Remove the debounce token for the given job.

Parameters

mixed $job
string $owner

Return Value

void

int|null getDebounceDelay(mixed $job)

Get the debounce delay for the given job.

Parameters

mixed $job

Return Value

int|null

int|null getMaxDebounceWait(mixed $job)

Get the maximum debounce wait time for the given job.

Parameters

mixed $job

Return Value

int|null

static string getKey(mixed $job)

Generate the cache key for the given job.

Parameters

mixed $job

Return Value

string

protected Repository resolveCache(mixed $job)

Resolve the cache store for the given job.

Parameters

mixed $job

Return Value

Repository