01 · Before and afterThe pattern
// before: blocks Redis while it walks every key in the database
const cycles = await redis.keys(`{${runId}}:wp:*`);
// after: read the counter the writer already keeps, then check existence in one round trip
const high = Number((await redis.hget(`{${runId}}:seq`, "c")) ?? 0);
const keys = Array.from({ length: high }, (_, i) => `{${runId}}:wp:${i + 1}`);
const p = redis.pipeline(); keys.forEach((k) => p.exists(k));
const found = (await p.exec())!.map(([, n], i) => (n ? keys[i] : null)).filter(Boolean);02 · Run it on your appThe check
Does any background job in your app call Redis KEYS (or an unbounded scan) on the same instance your requests use?
If the honest answer is no or not sure, this is worth a look before it reaches production.