MongoDB 用例清单
我正在建立一家在线零售商店,该商店在标记为“售完”之前显然有固定数量的衣服可供出售。假设由于衣服和其他物品迅速售罄,流量可能会非常高,我想使用 MongoDB 来跟踪库存。然而,这是 MongoDb 的最佳用例吗?
MongoDB 如何处理对单个文档的多次更新。
就我而言,假设有 10 件 T 恤,有 11 个人来到 smae 页面购买。现在,在购买时,我检查库存是否可用,然后执行更新以减少数量。 mongoDB 是否会对操作进行排队,以便进行前一个用户的更新,然后调用计数?
I am building an online retail store that has a fixed amount of clothes to sell obviously before its marked "sold-out". Assuming the traffic might get really high with clothes and other items selling out rapidly, I wanted to use MongoDB to track the inventory. However is this the best use-case for MongoDb.
How does MongoDB handle multiple updates to a single document.
In my case say there are 10 t-shirts, and 11 people come to the smae page to buy it. Now as there buying it, I check if the inventory is avaiable then perform an update decreasing the count. Will mongoDB queue the operations so that the update from a previous user is made and then the count is called?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MongoDB 有一个 findandmodify 函数,允许您进行原子更新。
http://www.mongodb.org/display/DOCS/findAndModify+Command
它应该允许你做
MongoDB has a findandmodify function that will allow you to do an atomic update.
http://www.mongodb.org/display/DOCS/findAndModify+Command
It should allow you to do
严格来说“用例”问题,我认为库存管理是传统上您会寻求事务 RDBMS 的目标。但这并不是说 MongoDB 不能或不会正常工作(正如其他人已经发布的那样),只是在我看来这不是标志性功能之一。
您可能会考虑将业务逻辑划分为两个部分:站点访问(可能非常高)和购买/交易(可能是访问的一小部分)。然后考虑前者的分布式内容交付的好处和后者的事务行为的好处。
Speaking strictly to the 'use case' question, I think inventory management is something you'd traditionally look toward a transactional RDBMS for. But it's not to say that MongoDB couldn't or wouldn't work fine (as others have already posted), just that it's not to my mind one of the hallmark features.
You might consider partitioning your business logic into two sections: site visits (presumably very high) and purchases/transactions (presumably some very small percentage of visits). Then consider the benefits of distributed content delivery for the former, and transactional behavior for the latter.