basalt / fastify/src / MemoryIdempotencyStore
Class: MemoryIdempotencyStore
Defined in: fastify/src/idempotency.ts:75
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.
Implements
Constructors
Constructor
> new MemoryIdempotencyStore(ttlMs?, clock?, options?): MemoryIdempotencyStore
Defined in: fastify/src/idempotency.ts:81
Parameters
ttlMs?
number = ...
clock?
() => number
options?
MemoryIdempotencyStoreOptions = {}
Returns
MemoryIdempotencyStore
Accessors
size
Get Signature
> get size(): number
Defined in: fastify/src/idempotency.ts:92
Number of retained entries (expired ones may linger until the next sweep).
Returns
number
Methods
complete()
> complete(key, record): void
Defined in: fastify/src/idempotency.ts:135
Parameters
key
string
record
Returns
void
Implementation of
get()
> get(key): "pending" | IdempotencyRecord | undefined
Defined in: fastify/src/idempotency.ts:114
A completed record, the string 'pending' for an in-flight request, or undefined.
Parameters
key
string
Returns
"pending" | IdempotencyRecord | undefined
Implementation of
release()
> release(key): void
Defined in: fastify/src/idempotency.ts:140
Release a reservation so the client can retry (e.g. after a 5xx).
Parameters
key
string
Returns
void
Implementation of
setPending()
> setPending(key): boolean
Defined in: fastify/src/idempotency.ts:124
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