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

Note in order to use KyselyLockAdapter 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/lock/kysely-lock-adapter"

Implements

Constructors

Methods

  • Removes a lock from the database only if owned by the specified lockId. Ownership verification prevents accidental deletion of locks held by others.

    Parameters

    • _context: IReadableContext
    • key: string

      Unique identifier for the lock

    • lockId: string

      The unique identifier of the expected lock owner

    Returns Promise<null | ILockData>

    Promise resolving to the lock's owner and expiration data if successfully removed, null if the lock wasn't found or the owner didn't match

  • Updates the expiration time of a lock if owned by the specified lockId. Ownership verification ensures only the lock owner can extend the lock.

    Parameters

    • _context: IReadableContext
    • key: string

      Unique identifier for the lock

    • lockId: string

      The unique identifier of the expected lock owner

    • expiration: Date

      The new date and time when the lock should expire

    Returns Promise<number>

    Promise resolving to the number of locks updated (1 if successful, 0 if not found or ownership mismatch)