使待处理的排队项目过期

编程入门 行业动态 更新时间:2024-10-24 20:16:51
本文介绍了使待处理的排队项目过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在建立一个网站,用户可以购买数量有限的活动门票.用户可以在我的网站上获得门票.一旦他们的购物车中有可用的票,他们将有固定的时间(5分钟)来完成交易.

I am building a site that users can buy a limited number of event tickets. The users can go on my site and get the tickets. Once they have available tickets in their cart, they will have a set amount of time(5 minutes) to complete the transaction.

如果他们在计时器到时之前完成了交易,则票据将从数据库可用性中永久删除.

If they complete the transaction before the timer is up the tickets are permanently removed from the database availability.

如果他们在5分钟前仍未完成交易,那么他们的分配将重新排入队列,以供公众订购.

If they don't complete the transaction before the 5 minutes then their allotment gets put back into the queue for the public to order from.

我的问题是,如果用户未在5分钟内完成交易,将这些物品放回公共队列的最佳方法是什么?请记住,用户只能关闭网站,因此后端永远不会意识到这一点.我的想法是,当用户将项目放入购物车中时,后端应将其放入数据库中的集合中.然后,当用户完成将由支持者清理的交易时,如果用户关闭浏览器或未及时完成交易,则后端将有一个CRON作业,该作业每1分钟运行一次以放置未付款的交易回到常规队列.

My question is what is the best method of putting these items back in the public queue if the user doesn't complete the transaction before the 5 minutes is up? Remember the user could just close the website so the backend would never be aware of that. My thought is that when a user puts the items in their cart the backend should put that into a collection in the db. Then when the user completes the transaction that will be cleaned up by the backed.IF the user closes the browser or doesn't complete the transaction in time then the backend would have a CRON job that runs every 1 minute to put un-paid transactions back into the general queue.

CRON工作方法是最佳途径吗?到目前为止,我已经想出了所有这些,但是想知道是否有更好的方法吗?

Is the CRON job method the best route? That's all I've come up with so far but was wanting to know if there was a better way?

推荐答案

您可以使用 Cloud Tasks 在回调到HTTP函数一个特定的时间.该函数可以执行到期.

You can use Cloud Tasks to schedule a callback to an HTTP function at a specific time. That function can perform the expiration.

或者,您可以定期检查要使用计划功能执行的工作,但是您必须接受计时的粒度最多可以偏离标记的一分钟.

Or, you can periodically check for work to be done with a scheduled function, but you'll have to accept that the granularity of timing will be up to one minute off the mark.

更多推荐

使待处理的排队项目过期

本文发布于:2023-11-09 20:25:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573347.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!