The acquire
method acquires a lock only if the lock 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 lock 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 lock 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 lock 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 was released or false if the lock doesnt exists
The getOwner
method return the current owner.
The getRemainingTime
return the reaming time as TimeSpan
.
Returns null if the key doesnt exist, key has no expiration and key has expired.
The isExpired
method returns true if the lock is expired otherwise false is returned.
The isLocked
method returns true if the lock is unexpirable or unexpired otherwise false is returned.
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 a different owner attempts to refresh the lock.
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 a different owner attempts to release the lock.
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"