如何为多个用户尝试在线预订同一座位的单个用户进行交易? [英] How transaction is made for single user where multiple users try to book tickets online for same seat ?

查看:89
本文介绍了如何为多个用户尝试在线预订同一座位的单个用户进行交易?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何处理这种情况。如果有两个座位可供选择.10个不同的人试图预订这两个座位的门票。然后最终座位预订仅针对单个人以及如何管理交易。



我尝试过的事情:



i认为它使用锁定概念,因为我对此不太熟悉一种情况。我希望你能帮助我。

how to handle such situation.if two seats are available.10 different people were trying to book tickets for those two seats .then finally seats booking is done for only single person and how transaction is managed.

What I have tried:

i thought its using lock concept as iam not much familier to this kind of scenarios .i hope you would help me.

推荐答案

数据库中座位的记录应该有某种锁定字段。当有人点击预订按钮时,它将使用当前时间更新锁定在字段。如果其他人试图预订一个非空锁定时间的座位,他们会被告知其他人正在预订。当用户取消预订然后清除该字段时,您也可以在预订时将其清除。棘手的是,你需要某种形式的自动化任务(SQL代理,计划任务,Windows服务,定时事件等)来清除已经过了10分钟的锁,并假设预订刚刚被放弃。
The record for the seat in the database should have some kind of "locked at" field. When someone clicks the "book" button it will update the "locked at" field with the current time. If someone else tries to book a seat with a non-null locked time they're told someone else is booking it. When the user cancels the booking then clear the field, you could also clear it when the booking is made. The tricky bit is that you then need some form of automated task (SQL agent, scheduled task, windows service, timed event etc) that clears locks that are over, say 10 minutes old and assume the booking was just abandoned.


这篇关于如何为多个用户尝试在线预订同一座位的单个用户进行交易?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆