/** * @module Lock */ import { type IReadableContext } from "../../../../execution-context/contracts/_module.js"; import { type ILockAdapter, type ILockAdapterState } from "../../../../lock/contracts/_module.js"; import { type TimeSpan } from "../../../../time-span/implementations/_module.js"; import { type IDeinitizable } from "../../../../utilities/_module.js"; /** * IMPORT_PATH: `"@daiso-tech/core/lock/memory-lock-adapter"` * @group Adapters */ export type MemoryLockData = { owner: string; hasExpiration: true; timeoutId: string | number | NodeJS.Timeout; expiration: Date; } | { owner: string; hasExpiration: false; }; /** * Note the `MemoryLockAdapter` is limited to single process usage and cannot be shared across multiple servers or different processes. * This adapter is meant for easily faking{@link ILockFactory | `ILockFactory`} for testing. * * IMPORT_PATH: `"@daiso-tech/core/lock/memory-lock-adapter"` * @group Adapters */ export declare class MemoryLockAdapter implements ILockAdapter, IDeinitizable { private readonly map; /** * @example * ```ts * import { MemoryLockAdapter } from "@daiso-tech/core/lock/memory-lock-adapter"; * * const lockAdapter = new MemoryLockAdapter(); * ``` * You can also provide an `Map`. * @example * ```ts * import { MemoryLockAdapter } from "@daiso-tech/core/lock/memory-lock-adapter"; * * const map = new Map(); * const lockAdapter = new MemoryLockAdapter(map); * ``` */ constructor(map?: Map); /** * Removes all in-memory lock data. */ deInit(): Promise; acquire(key: string, lockId: string, ttl: TimeSpan | null, _context: IReadableContext): Promise; release(key: string, lockId: string, _context: IReadableContext): Promise; forceRelease(key: string, _context: IReadableContext): Promise; refresh(key: string, lockId: string, ttl: TimeSpan, _context: IReadableContext): Promise; getState(key: string, _context: IReadableContext): Promise; }