UNPKG

@daiso-tech/core

Version:

The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.

38 lines (37 loc) 1.34 kB
/** * @module Lock */ import type { TimeSpan } from "../../../../utilities/_module-exports.js"; import type { ILockAdapter, ILockData } from "../../../../lock/contracts/_module-exports.js"; /** * Note the `MemoryLockAdapter` is limited to single process usage and cannot be shared across multiple servers or different processes. * This adapter is meant to be used for testing. * * IMPORT_PATH: `"@daiso-tech/core/lock/adapters"` * @group Adapters */ export declare class MemoryLockAdapter implements ILockAdapter { private readonly map; private readonly timeoutMap; /** * @example * ```ts * import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters"; * * const lockAdapter = new MemoryLockAdapter(); * ``` * You can also provide an `Map`. * @example * ```ts * import { MemoryLockAdapter } from "@daiso-tech/core/lock/adapters"; * * const map = new Map<any, any>(); * const lockAdapter = new MemoryLockAdapter(map); * ``` */ constructor(map?: Map<string, ILockData>); acquire(key: string, owner: string, ttl: TimeSpan | null): Promise<boolean>; release(key: string, owner: string): Promise<boolean>; forceRelease(key: string): Promise<void>; refresh(key: string, owner: string, time: TimeSpan): Promise<boolean>; }