UNPKG

@daiso-tech/core

Version:

The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.

33 lines (32 loc) 1.32 kB
/** * @module Lock */ import type { TimeSpan } from "../../utilities/_module-exports.js"; /** * The `ILockAdapter` contract defines a way for managing locks independent of the underlying technology. * This contract is not meant to be used directly, instead you should use {@link ILockProvider | `ILockProvider`} contract. * * IMPORT_PATH: `"@daiso-tech/core/lock/contracts"` * @group Contracts */ export type ILockAdapter = { /** * The `acquire` method acquires a lock only if the lock is not already acquired. * Returns true if not already acquired othewise false is returned. */ acquire(key: string, owner: string, ttl: TimeSpan | null): PromiseLike<boolean>; /** * The `release` method releases a lock if the owner matches. * Returns true if released otherwise false is returned. */ release(key: string, owner: string): PromiseLike<boolean>; /** * The `forceRelease` method releases a lock regardless of the owner. */ forceRelease(key: string): PromiseLike<void>; /** * The `refresh` method will upadte ttl of lock if it matches the given `key` and matches the given `owner`. * Returns true if the update occured otherwise false is returned. */ refresh(key: string, owner: string, ttl: TimeSpan): PromiseLike<boolean>; };