Offers locking a mechanism to prevent race conditions.

Implements

Constructors

Methods

Constructors

  • Parameters

    • redis: RedisClientType<RedisModules>
    • Optionaloptions: { retryTime?: number }

    Returns default

Methods

  • Type Parameters

    • T

    Parameters

    • key: string

      the key of the resource to lock

    • callback: () => Promise<T>

      the code which should run once the lock was acquired

    • options: { maxOccupationTime: number; timeout: number }

    Returns Promise<T>

    'timeout' or 'occupation-time-exceed' errors