The acquire
method acquires a lock only if the key is not already acquired by different owner.
Returns true if the lock is not already acquired otherwise false is returned.
The acquireBlocking
method acquires a lock only if the key is not already acquired by different owner.
If the lock is not acquired, it retries every settings.interval
until settings.time
is reached.
Optional
settings: LockAquireBlockingSettingsReturns true if the lock is not already acquired otherwise false is returned.
The acquireBlockingOrFail
method acquires a lock only if the key is not already acquired by different owner.
If the lock is not acquired, it retries every settings.interval
until settings.time
is reached.
Throws an error if the lock is already acquired by different owner.
Optional
settings: LockAquireBlockingSettingsThe acquireOrFail
method acquires a lock only if the key is not already acquired by different owner.
Throws an error if the lock is already acquired by different owner.
The forceRelease
method releases a lock regardless of the owner.
Returns true if the lock exists or false if the lock doesnt exists.
The refresh
method updates the ttl
of the lock if expireable and owned by the same owner.
Optional
ttl: TimeSpanReturns true if the lock is refreshed otherwise false is returned.
The refreshOrFail
method updates the ttl
of the lock if expireable and owned by the same owner.
Throws an error if the lock is not owned by same owner.
Throws an error if the key is unexpirable.
Optional
ttl: TimeSpanThe release
method releases a lock if owned by the same owner.
Returns true if the lock is released otherwise false is returned.
The releaseOrFail
method releases a lock if owned by the same owner.
Throws an error if the lock is not owned by same owner.
The run
method wraps an Invokable
or LazyPromise
with the acquire
and release
method.
The runBlocking
method wraps an Invokable
or LazyPromise
with the acquireBlocking
and release
method.
Optional
settings: LockAquireBlockingSettingsThe runBlockingOrFail
method wraps an Invokable
or LazyPromise
with the acquireBlockingOrFail
and release
method.
Optional
settings: LockAquireBlockingSettingsThe runOrFail
method wraps an Invokable
or LazyPromise
with the acquireOrFail
and release
method.
IMPORT_PATH:
"@daiso-tech/core/lock/contracts"