本文介绍了如何处理库存和并发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有哪些策略可以应对看似有限的库存和订单的常见情况。

What are strategies to deal with seemingly common scenario of a limited inventory and an order form.

如果剩下一件物品,两个人试图同时购买。

If there is one item left, and two people attempt to purchase at the same time. How do you deal with whoever submits payment last?

推荐答案

当用户向他们的购物车中添加限量商品时,您该如何处理?按住该商品一小段时间-例如15分钟。如果他们在窗口内付款,则归他们所有,否则保留将被取消,并将商品退还至游泳池。 (在保留期间,该项目被认为对其他用户不可用。)

When a user adds a limited-supply item to their shopping cart, put a hold on the item for a small window of time - say, 15 minutes. It's theirs if they pay within the window, otherwise the hold is removed and the item is returned to the pool. (For the duration of the hold, the item considered "not available" to other users.)

AFAIK,这是非常标准的技术-我见过做到这一点。

AFAIK, it's pretty standard technique - I've seen Gilt do this, for instance.

这篇关于如何处理库存和并发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 06:50