The acquire method acquires a lock only if the lock is not already acquired. Returns true if the lock is acquired otherwise false is returned.
The acquireBlocking method acquires a lock only if the lock is not already acquired. If the lock is acquired, it retries every settings.interval until settings.time is reached. Returns true if the lock is acquired otherwise false is returned.
Optional
settings: AquireBlockingSettingsThe acquireOrFail method acquires a lock only if the lock is not already acquired. Throws an error if already acquired.
The forceRelease method releases a lock regardless of the owner.
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 expired otherwise false is returned.
The isLocked method returns true if the locked otherwise false is returned.
The refresh method updates the TTL of the lock if owned by the same owner. Returns true if the lock is refreshed occurs otherwise false is returned.
Optional
ttl: TimeSpanThe refreshOrFail method updates the TTL of the lock if owned by the same owner. Throws an error if a different owner attempts to refresh the lock.
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 async function or LazyPromise with the acquire and release method.
The runBlocking method wraps an async function or LazyPromise with the acquireBlocking and release method.
Optional
settings: AquireBlockingSettingsThe runOrFail method wraps an async function or LazyPromise with the acquireOrFail and release method.
IMPORT_PATH:
"@daiso-tech/core/lock/contracts"