basalt / fastify/src / IdempotencyStore
Interface: IdempotencyStore
Defined in: fastify/src/idempotency.ts:51
Persists idempotency outcomes. Default in-memory; swap RedisIdempotencyStore to share replays across instances. Methods may be sync or async — the plugin awaits them — so the in-process store stays synchronous while a Redis one doesn't.
Methods
complete()
> complete(key, record): void | Promise<void>
Defined in: fastify/src/idempotency.ts:62
Parameters
key
string
record
Returns
void | Promise<void>
get()
> get(key): "pending" | IdempotencyRecord | Promise<"pending" | IdempotencyRecord | undefined> | undefined
Defined in: fastify/src/idempotency.ts:53
A completed record, the string 'pending' for an in-flight request, or undefined.
Parameters
key
string
Returns
"pending" | IdempotencyRecord | Promise<"pending" | IdempotencyRecord | undefined> | undefined
release()
> release(key): void | Promise<void>
Defined in: fastify/src/idempotency.ts:64
Release a reservation so the client can retry (e.g. after a 5xx).
Parameters
key
string
Returns
void | Promise<void>
setPending()
> setPending(key): boolean | Promise<boolean>
Defined in: fastify/src/idempotency.ts:61
Atomically reserve the key iff it is free. Returns true when this caller won the reservation, false when a record (pending or completed) already exists — the caller must then get() to decide replay vs. conflict. The check-and-set MUST be atomic so two concurrent first-time requests can't both win (Redis SET NX, a single synchronous step in-process).
Parameters
key
string
Returns
boolean | Promise<boolean>