Pluggable dedupe contract for at-least-once delivery. Implement this over any shared store (Redis SET key NX PX, a unique DB column) for multi-instance deployments; add returns (or resolves) true when the key was already seen.
SET key NX PX
add
true
// Redis adapter (multi-instance safe):const store: DedupeStore = { async add(key) { const ok = await redis.set(`wh:${key}`, "1", "PX", 86_400_000, "NX"); return ok === null; // null = key already existed → duplicate },}; Copy
// Redis adapter (multi-instance safe):const store: DedupeStore = { async add(key) { const ok = await redis.set(`wh:${key}`, "1", "PX", 86_400_000, "NX"); return ok === null; // null = key already existed → duplicate },};
Readonly
Record a key. Returns true if it was already present (a duplicate).
Pluggable dedupe contract for at-least-once delivery. Implement this over any shared store (Redis
SET key NX PX, a unique DB column) for multi-instance deployments;addreturns (or resolves)truewhen the key was already seen.Example