IWriterLock: {
    acquireWriter(): Promise<boolean>;
    acquireWriterOrFail(): Promise<void>;
    forceReleaseWriter(): Promise<boolean>;
    refreshWriter(ttl?: ITimeSpan): Promise<boolean>;
    refreshWriterOrFail(ttl?: ITimeSpan): Promise<void>;
    releaseWriter(): Promise<boolean>;
    releaseWriterOrFail(): Promise<void>;
    runWriterOrFail<TValue = void>(asyncFn: AsyncLazy<TValue>): Promise<TValue>;
}

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

Type declaration

  • acquireWriter:function
    • The acquireWriter method acquires a lock only if the key is not already acquired by different owner.

      Returns Promise<boolean>

      Returns true if the lock is not already acquired otherwise false is returned.

  • acquireWriterOrFail:function
    • The acquireWriterOrFail 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.

      Returns Promise<void>

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

      Returns Promise<boolean>

      Returns true if the lock exists or false if the lock doesnt exists.

  • refreshWriter:function
  • refreshWriterOrFail:function
    • The refreshWriterOrFail 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.

      Parameters

      Returns Promise<void>

  • releaseWriter:function
  • releaseWriterOrFail:function
  • runWriterOrFail:function