method IDistributedLock.acquire
IDistributedLock.acquire(
key: string,
ttlMs: number
): Promise<string | null>

Attempt to acquire the lock.

Parameters

key: string

The lock key

ttlMs: number

Time-to-live in milliseconds

Return Type

Promise<string | null>

A unique token if acquired, or null if held by another instance

Usage

import { type IDistributedLock } from "scheduler-plugin/src/index.ts";