Options
All
  • Public
  • Public/Protected
  • All
Menu

A locking system that uses a Redis server or any number of Redis nodes / clusters This solution has issues though:

  • Redlock wants to handle expiration itself, this is against the design of a ResourceLocker. The workaround for this is to extend an active lock indefinitely.
  • This solution is not multithreaded! If threadA locks a resource, only threadA can unlock this resource. If threadB wont be able to lock a resource if threadA already acquired that lock, in that sense it is kind of multithreaded.
  • Redlock does not provide the ability to see which locks have expired

Hierarchy

  • RedisResourceLocker

Implements

Index

Constructors

  • new RedisResourceLocker(redisClients: string[], redlockOptions?: Record<string, number>): RedisResourceLocker

Properties

lockMap: Map<string, { interval: Timeout; lock: Lock }>
logger: Logger = ...
redlock: Redlock

Methods

  • createRedisClients(redisClientsStrings: string[]): RedisClient[]
  • Generate and return a list of RedisClients based on the provided strings

    Parameters

    • redisClientsStrings: string[]

      a list of strings that contain either a host address and a port number like '127.0.0.1:6379' or just a port number like '6379'

    Returns RedisClient[]

  • createRedlock(clients: RedisClient[], redlockOptions?: Record<string, number>): Redlock
  • Generate and return a Redlock instance

    Parameters

    • clients: RedisClient[]

      a list of RedisClients you want to use for the redlock instance

    • redlockOptions: Record<string, number> = {}

      extra redlock options to overwrite the default config

    Returns Redlock

  • extendLockIndefinitely(identifier: string): Timeout
  • This function is internally used to keep an acquired lock active, a wrapper class will handle expiration

    Parameters

    • identifier: string

      Identifier of the lock to be extended

    Returns Timeout

  • finalize(): Promise<void>
  • getLockCount(): number