Type Alias IDatabaseSemaphoreAdapter

IDatabaseSemaphoreAdapter: {
    removeAllSlots(key: string): Promise<ISemaphoreSlotExpirationData[]>;
    removeSlot(
        key: string,
        slotId: string,
    ): Promise<null | ISemaphoreSlotExpirationData>;
    transaction<TValue>(
        fn: InvokableFn<
            [transaction: IDatabaseSemaphoreTransaction],
            Promise<TValue>,
        >,
    ): Promise<TValue>;
    updateExpiration(
        key: string,
        slotId: string,
        expiration: Date,
    ): Promise<number>;
}

The IDatabaseSemaphoreAdapter contract defines a way for managing semaphores independent of data storage. This contract simplifies the implementation of semaphore adapters with CRUD-based databases, such as SQL databases and ORMs like TypeOrm and MikroOrm.

IMPORT_PATH: "@daiso-tech/core/semaphore/contracts"

Type declaration