System Design Quiz Practice
Active Recall Drill Session
← Exit SessionQuestion 1 of 1
mediumSystem Design
In the idempotent processPayment example, what does the idempotencyKey check accomplish?
code
async function processPayment(message) {
const already = await db.paymentEvents.findOne({ idempotencyKey: message.messageId });
if (already) return;
await chargeCard(message.customerId, message.amount);
await db.paymentEvents.insert({ idempotencyKey: message.messageId });
}