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.

48 lines (47 loc) 1.4 kB
/** * @module Lock */ import type { IDatabaseLockAdapter, ILockData } from "../../../../lock/contracts/_module-exports.js"; import type { Kysely } from "kysely"; import { type IDeinitizable, type IInitizable, TimeSpan } from "../../../../utilities/_module-exports.js"; /** * @internal */ type KyselyLockTable = { key: string; owner: string; expiresAt: number | null; }; /** * @internal */ type KyselyTables = { lock: KyselyLockTable; }; /** * @internal */ type KyselySettings = { database: Kysely<KyselyTables>; expiredKeysRemovalInterval?: TimeSpan; shouldRemoveExpiredKeys?: boolean; }; /** * @internal */ export declare class KyselyLockAdapter implements IDatabaseLockAdapter, IDeinitizable, IInitizable { private readonly database; private readonly expiredKeysRemovalInterval; private readonly shouldRemoveExpiredKeys; private timeoutId; constructor(settings: KyselySettings); deInit(): Promise<void>; init(): Promise<void>; removeExpiredKeys(): Promise<void>; insert(key: string, owner: string, expiration: Date | null): Promise<void>; update(key: string, owner: string, expiration: Date | null): Promise<number>; remove(key: string, owner: string | null): Promise<void>; refresh(key: string, owner: string, expiration: Date): Promise<number>; find(key: string): Promise<ILockData | null>; } export {};