To utilize the KyselySemaphoreAdapter, you must install the "kysely" package and configure a Kysely class instance.

Note in order to use KyselySemaphoreAdapter correctly, ensure you use a single, consistent database across all server instances and use a database that has support for transactions. The adapter have been tested with sqlite, postgres and mysql databases.

IMPORT_PATH: "@daiso-tech/core/semaphore/kysely-semaphore-adapter"

Implements

Constructors

Methods

  • Updates a slot's expiration time if it's currently valid (not expired). Useful for extending a held slot's lifetime (e.g., heartbeat/keep-alive).

    Conditions for success:

    • Slot must exist
    • Slot must not be expired (expiration time >= current time or null)
    • New expiration must be in the future

    Parameters

    • _context: IReadableContext
    • key: string

      The semaphore identifier

    • slotId: string

      The slot to update

    • expiration: Date

      New expiration time (or null for persistent)

    Returns Promise<number>

    Number of rows affected (1 if updated, 0 if slot not found or expired)