redlock-universal
    Preparing search index...

    Interface Lock

    Abstract base class for all lock implementations

    interface Lock {
        acquire(): Promise<LockHandle>;
        extend(handle: LockHandle, ttl: number): Promise<boolean>;
        getAdapter(): RedisAdapter | null;
        isLocked(key: string): Promise<boolean>;
        release(handle: LockHandle): Promise<boolean>;
        using<T>(routine: (signal: ExtendedAbortSignal) => Promise<T>): Promise<T>;
    }

    Implemented by

    Index

    Methods

    • Extend the TTL of an existing lock

      Parameters

      • handle: LockHandle

        Lock handle from acquire()

      • ttl: number

        New TTL in milliseconds

      Returns Promise<boolean>

      Promise resolving to true if extended, false if lock expired

    • Get the underlying Redis adapter for atomic operations

      Returns RedisAdapter | null

      Redis adapter instance or null if not applicable (e.g., for RedLock with multiple adapters)

    • Check if a lock is currently held

      Parameters

      • key: string

        Lock key to check

      Returns Promise<boolean>

      Promise resolving to true if locked, false otherwise

    • Release a previously acquired lock

      Parameters

      Returns Promise<boolean>

      Promise resolving to true if released, false if already expired

    • Execute a routine with automatic lock management and extension Auto-extends when remaining TTL < 20% (extends at ~80% consumed) Provides ExtendedAbortSignal when extension fails

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

      Promise resolving to the routine result