Type Alias ILockAdapter

ILockAdapter: {
    acquire(
        key: string,
        lockId: string,
        ttl: null | TimeSpan,
    ): Promise<boolean>;
    forceRelease(key: string): Promise<boolean>;
    getState(key: string): Promise<null | ILockAdapterState>;
    refresh(key: string, lockId: string, ttl: TimeSpan): Promise<boolean>;
    release(key: string, lockId: string): Promise<boolean>;
}

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 ILockProvider contract.

IMPORT_PATH: "@daiso-tech/core/lock/contracts"

Type declaration

  • acquire:function
    • The acquire method acquires a lock only if expired.

      Parameters

      • key: string
      • lockId: string
      • ttl: null | TimeSpan

      Returns Promise<boolean>

      Returns true if expired otherwise false is returned.

  • forceRelease:function
    • The forceRelease method releases a lock regardless of the owner.

      Parameters

      • key: string

      Returns Promise<boolean>

      Returns true if the lock exists or false if the lock is expired.

  • getState:function
  • refresh:function
    • The refresh method will upadte ttl of lock if it matches the owner and is expireable.

      Parameters

      Returns Promise<boolean>

      Returns false if the lock is unexpireable, the is expired, does not match the owner otherwise true is returned.

  • release:function
    • The release method releases a lock if the owner matches.

      Parameters

      • key: string
      • lockId: string

      Returns Promise<boolean>

      Returns true if released otherwise false is returned.