class ConcurrencyLimiter (View source)

Properties

protected LockProvider $store

The cache store instance.

protected string $name

The name of the limiter.

protected int $maxLocks

The allowed number of concurrent locks.

protected int $releaseAfter

The number of seconds a slot should be maintained.

Methods

__construct(LockProvider $store, string $name, int $maxLocks, int $releaseAfter)

Create a new concurrency limiter instance.

mixed
block(int $timeout, callable|null $callback = null, int $sleep = 250)

Attempt to acquire the lock for the given number of seconds.

Lock|false
acquire(string $id)

Attempt to acquire a slot lock.

void
release(Lock $lock)

Release the lock.

Details

__construct(LockProvider $store, string $name, int $maxLocks, int $releaseAfter)

Create a new concurrency limiter instance.

Parameters

LockProvider $store
string $name
int $maxLocks
int $releaseAfter

mixed block(int $timeout, callable|null $callback = null, int $sleep = 250)

Attempt to acquire the lock for the given number of seconds.

Parameters

int $timeout
callable|null $callback
int $sleep

Return Value

mixed

Exceptions

LimiterTimeoutException
Throwable

protected Lock|false acquire(string $id)

Attempt to acquire a slot lock.

Parameters

string $id

Return Value

Lock|false

protected void release(Lock $lock)

Release the lock.

Parameters

Lock $lock

Return Value

void

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.