UNPKG

node-redisson

Version:

Distributed lock with Redis implementation for Node.js

39 lines (38 loc) 1.9 kB
import { ICommandExecutor } from '../contracts/ICommandExecutor'; import { IRLock, RLockLeaseTime, RLockWaitTime } from '../contracts/IRLock'; import { TimeUnit } from '../utils/TimeUnit'; export type LockClientId = string; export declare abstract class RedissonBaseLock implements IRLock { protected readonly commandExecutor: ICommandExecutor; private static readonly EXPIRATION_RENEWAL_MAP; protected id: string; protected lockName: string; protected _clientId: LockClientId; protected internalLockLeaseTime: bigint; protected readonly entryName: string; static prefixName(prefix: string, name: string): string; constructor(commandExecutor: ICommandExecutor, lockName: string, clientId?: string); get name(): string; get clientId(): LockClientId; abstract tryLock(waitTime: RLockWaitTime, leaseTime: RLockLeaseTime, unit?: TimeUnit): Promise<boolean>; abstract lock(leaseTime?: RLockLeaseTime, unit?: TimeUnit): Promise<void>; abstract forceUnlock(): Promise<boolean>; abstract unlockInner(clientId: LockClientId, requestId: string, timeout: number): Promise<boolean | null>; unlock(): Promise<void>; isLocked(): Promise<boolean>; protected getClientName(clientId: LockClientId): string; protected getUnlockLatchName(requestId: string): string; protected scheduleExpirationRenewal(clientId: LockClientId): void; protected renewExpiration(): void; protected cancelExpirationRenewal(unlockResult: boolean, clientId?: LockClientId): void; } export declare class ExpirationEntry { timeoutId?: NodeJS.Timeout; private clientsQueue; private readonly clientIds; addClientId(clientId: LockClientId): void; removeClientId(clientId: LockClientId): void; get hasNoClients(): boolean; get firstClientId(): string; getClientCounter(clientId: string, defaultCounter?: number): number; }