Files
2026-04-21 22:34:39 +08:00

23 lines
817 B
TypeScript

import { RedisService } from './redis.service';
export interface LockOptions {
ttl?: number;
retryDelay?: number;
maxRetries?: number;
timeout?: number;
fallback?: (attempt: number) => Promise<unknown>;
}
export declare class DistributedLockService {
private readonly redisService;
private readonly logger;
private readonly LOCK_PREFIX;
constructor(redisService: RedisService);
acquireLock(resource: string, options?: LockOptions): Promise<{
success: boolean;
identifier?: string;
}>;
releaseLock(resource: string, identifier: string): Promise<boolean>;
renewLock(resource: string, identifier: string, ttl: number): Promise<boolean>;
withLock<T>(resource: string, task: () => Promise<T>, options?: LockOptions): Promise<T>;
private delay;
}