处理多用户环境
这是我第一次开发一个可供 10-15 人同时使用的应用程序,所以我不太确定有什么好方法可以最大限度地减少更新冲突。
本质上,我的应用程序的工作原理如下。新项目在收到后会通过外部服务插入到数据库中。业务规则表明每个项目都应由两名独立员工审核。不用说,商品和评论之间存在一对多的关系。该应用程序最的一个方面是,任何项目都不能超过两个评论,并且系统必须跟踪两个评论者是谁。另外,第一审稿人和第二审稿人是谁。
现在,我一切正常。我正在处理的问题是这个(许多类似场景之一)。如果所有用户在同一 5 分钟内刷新其商品列表,会发生什么情况?用户 1 提交了对商品 ID 1 的评论。第二个人提交了对同一商品的评论。现在,第三人提交了对商品 ID 1 的评论,但已有 2 条评论,因此该商品已标记为完成。
有哪些可能的方法来处理多用户环境,其中多个用户很有可能更新同一条记录?
This is my first time developing an application that will be used by 10-15 people concurentlyso I'm not exactly sure of a good way to minimize update collisions.
Essentially, my application works as follows. New items get inserted into the database via an external service as they get received. Business rules indicate that each item is to be reviewed by two independant employees. Needless to say, there is a one-to-many relationship between the item and reviews. What is the most important aspect of the application is that no item can exceed two reviews and the system must keep track of who were the two reviewers. Also, who acted as the first reviewer and second.
Now, I have everything working. The issue I'm dealing with is this (one of many simmilar scenarios). What happens if all users refreshed their item listing within the same 5 minutes of eachother. User 1 submits a review for item id 1. A second person submits a review on the same item. Now a third person submits a review on item id 1 but there are already 2 reviews so the item has been marked as complete.
What are possible ways to deal with a multi-user environment where there is a great possibility of several users updating the same record?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道您的应用程序的详细信息,但似乎进行审查的过程扩大了多个人可以开始审查的窗口,然后当他们提交时最终会超过两个,
一个选择是引入这个概念开始审查。当某人发起进行审核的操作时,他们“开始”审核。这标志着审查已经开始。系统不应让超过两个启动。
您还可以通过超时我们从未“提交”的评论或能够删除已开始的待处理评论来使其更高级。
I don't know the details of your app but it seems like the process of doing a review widens the window where multiple folks can start a review and then when they commit it ends up being more than two,
One option is to introduce the concept of starting a review. When someone initiates the action of doing a review, they "start" the review. That marks the review as started. The system shouldn't let more than two starting.
You could also make it more advanced by timing out reviews that we're never "submitted" or having the ability to delete a pending review that was started.
Nhibernate 有多种并发模型,您可以根据需要在项目中实现这些模型。
看看 NHibernate-Concurrency
Nhibernate has various concurreny models which you implement in your project based upon your needs.
Have a look at NHibernate-Concurrency