app.get("/handle-work/:workid", async (req, res) => {
const workid = req.params.workid;
const work = await client.get(workid);
if (!work) {
res.send("The work already done:" + workid);
return;
}
// do something sync
// clean redis cache
await client.del(workid);
res.send("Handle:" + workid);
});
这种写法可能会导致一个 workid 被处理两次。 应该如何避免呢? 谢谢