UNPKG

@shagital/atomic-lock

Version:

Universal atomic locking with pluggable drivers (Redis, SQLite, File, Memory)

22 lines (21 loc) 873 B
import { LockDriver, LockInfo } from '../types'; /** * In-memory driver implementation (for testing and single-process scenarios) */ export declare class MemoryLockDriver implements LockDriver { private locks; private cleanupInterval?; constructor(config?: { cleanupInterval?: number; }); tryAcquire(key: string, lockValue: string, expiryInSeconds: number): Promise<boolean>; tryAcquireMultiple(keys: string[], lockValue: string, expiryInSeconds: number): Promise<boolean>; release(key: string, lockValue: string): Promise<boolean>; releaseMultiple(keys: string[], lockValue: string): Promise<number>; exists(key: string): Promise<boolean>; getLockInfo(key: string): Promise<LockInfo | null>; cleanup(): Promise<void>; close(): Promise<void>; getLockCount(): number; getAllLocks(): Map<string, LockInfo>; }