idempotency
●cart · /core·function
Built-in middleware that deduplicates mutations sharing the same
ctx.idempotencyKey within windowMs. Replays return the cached cart
without invoking the inner chain. Mutations without a key pass through
unaltered.
Signature
function idempotency(opts: { store: IdempotencyStore; windowMs: number }): CartMiddleware;Parameters
| Name | Type | Description |
|---|---|---|
opts | { store: IdempotencyStore; windowMs: number } |
Returns
A that short-circuits duplicates.
Example
const kernel = createCart({
adapter,
middleware: [idempotency({ store: memoryIdempotencyStore(), windowMs: 30_000 })],
});Related
RunCartAdapterContractOpts runCartAdapterContract CartCapabilityUnsupportedError CartError CartNotFoundError CartProviderError CartUserError CartAdapter
MetadataOpen in GitHub ↗
IdempotencyStore
Backing store contract for the middleware. Implementations persist successful mutation results keyed by idempotency token so that duplicate requests within the
KV
Generic keyvalue pair used for cart attributes and line item attributes. Adapters map these to providerspecific metadata fields.