import { ILockingProvider, Logger } from "@medusajs/types"; import { RedisCacheModuleOptions } from "../types/index.js"; import { Redis } from "ioredis"; type LockCommands = { acquireLock: (key: string, ownerId: string, ttl: number, awaitQueue?: boolean) => Promise; releaseLock: (key: string, ownerId: string) => Promise; extendLock: (key: string, ownerId: string, ttl: number) => Promise; }; type InjectedDependencies = { redisClient: Redis & LockCommands; prefix?: string; logger?: Logger; }; export declare class RedisLockingProvider implements ILockingProvider { static identifier: string; protected redisClient: Redis & LockCommands; protected keyNamePrefix: string; protected logger_?: Logger; protected waitLockingTimeout: number; protected defaultRetryInterval: number; protected maximumRetryInterval: number; protected backoffFactor: number; constructor({ redisClient, prefix, logger }: InjectedDependencies, options: RedisCacheModuleOptions); private getKeyName; /** * Runs `job` while holding `keys`, and keeps holding them for as long as it * runs: the lease is renewed underneath the job, so a job that outlives * `expire` no longer has its keys handed to another process mid-flight. * * The lease itself stays short regardless of how long the job takes — it is * what frees the keys if this process dies before reaching the release * below. When renewal loses the race anyway (Redis unreachable long enough * for the lease to lapse, or the key evicted), `job`'s signal is aborted and * `execute` throws, rather than reporting a critical section that wasn't one. */ execute(keys: string | string[], job: (signal?: AbortSignal) => Promise, args?: { timeout?: number; expire?: number; }): Promise; /** * Extends the lease on `keys` every third of its duration for as long as the * returned handle is live, so two renewals can fail before the keys become * available to anyone else. * * A renewal that reports the key as gone or owned by someone else is * definitive — no later renewal can win it back — so the signal aborts. */ private renewUntilStopped; acquire(keys: string | string[], args?: { ownerId?: string; expire?: number; awaitQueue?: boolean; }): Promise; acquire_(keys: string | string[], args?: { ownerId?: string; expire?: number; awaitQueue?: boolean; }, cancellationToken?: { cancelled: boolean; }): Promise; release(keys: string | string[], args?: { ownerId?: string | null; }): Promise; shutdown(): Promise; releaseAll(args?: { ownerId?: string | null; }): Promise; private getTimeout; } export {}; //# sourceMappingURL=redis-lock.d.ts.map