Skip to content

Documents for @litert/idempotency / Types / IStorageAdapter

Interface: IStorageAdapter

Defined in: src/lib/Types.ts:29

The adapter interface for storage operations.

Remember that this interface does not requires the deletion of records, as the logics of cleaning up old records is up to the implementation of the storage adapter.

Methods

create()

create(data): Promise<boolean>

Defined in: src/lib/Types.ts:42

Create a new idempotency record in the storage.

This method must be atomic, and it should not allow overwriting an existing record.

Parameters

data

IStoredRecord

The idempotency record to create.

Returns

Promise<boolean>

A promise that resolves to true if the record was created successfully, false if it already exists.


get()

get(key): Promise<null | IStoredRecord>

Defined in: src/lib/Types.ts:49

Retrieve an idempotency record by its key from the storage.

Parameters

key

string

The unique key for this operation, used to ensure idempotency.

Returns

Promise<null | IStoredRecord>


update()

update(data): Promise<void>

Defined in: src/lib/Types.ts:57

Update the idempotency record in the storage, from PENDING to SUCCESS or FAILED.

Parameters

data

Omit<IStoredRecord, "context">

The idempotency record to update.

Returns

Promise<void>