redlock-universal
    Preparing search index...

    Class GlideAdapter

    Redis adapter for Valkey GLIDE clients. Provides unified interface for GLIDE-specific operations.

    GLIDE (GLIde for Distributed Execution) is Valkey's official client library that supports both Valkey and Redis servers.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    options: Required<Omit<RedisAdapterOptions, "logger">> & { logger?: Logger }
    scriptSHAs: Map<string, string> = ...

    Methods

    • Atomic extension with TTL feedback and race condition protection

      Parameters

      • key: string

        Redis key

      • value: string

        Expected value

      • minTTL: number

        Minimum TTL required for extension (race condition protection)

      • newTTL: number

        New TTL to set in milliseconds

      Returns Promise<AtomicExtensionResult>

      Promise resolving to atomic extension result with TTL feedback

    • Atomically acquire multiple locks in a single operation All-or-nothing semantics: either all locks are acquired or none

      Parameters

      • keys: string[]

        Array of Redis keys to lock

      • values: string[]

        Array of values (one per key, same length as keys)

      • ttl: number

        Time to live in milliseconds for all locks

      Returns Promise<BatchAcquireResult>

      Promise resolving to batch acquisition result

      Error if keys and values arrays have different lengths

    • Delete key only if value matches (atomic operation)

      Parameters

      • key: string

        Redis key

      • value: string

        Expected value

      Returns Promise<boolean>

      Promise resolving to true if deleted, false otherwise

    • Extend TTL of a key only if value matches (atomic operation)

      Parameters

      • key: string

        Redis key

      • value: string

        Expected value

      • ttl: number

        New TTL in milliseconds

      Returns Promise<boolean>

      Promise resolving to true if extended, false otherwise

    • Get value by key

      Parameters

      • key: string

        Redis key

      Returns Promise<string | null>

      Promise resolving to value or null if not found

    • Interpret atomic extension script result into structured response

      Parameters

      • key: string
      • minTTL: number
      • scriptResult: [number, number]

      Returns AtomicExtensionResult

    • Parse batch acquisition script result into BatchAcquireResult Ensures consistent handling across all adapters

      Parameters

      • result: [number, number, string?]

        Lua script result [resultCode, countOrIndex, failedKey?]

      • keys: string[]

        Original keys array for fallback lookup

      Returns BatchAcquireResult

      BatchAcquireResult object

    • Parse inspection script result into LockInspection object Ensures consistent handling of Lua array return value across all adapters

      Parameters

      • result: [string, number] | null

        Lua script result [value, ttl] or null

      Returns LockInspection | null

      LockInspection object or null if key doesn't exist

    • Set key with value if not exists, with TTL in milliseconds

      Parameters

      • key: string

        Redis key

      • value: string

        Value to set

      • ttl: number

        Time to live in milliseconds

      Returns Promise<string | null>

      Promise resolving to 'OK' on success, null if key exists

    • Handles timeout for Redis operations Properly cleans up timeout handles to prevent memory leaks Uses .unref() to allow Node.js to exit even if timeout is pending

      Type Parameters

      • T

      Parameters

      • operation: Promise<T>
      • timeoutMs: number = ...

      Returns Promise<T>