Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a specific requirement. Lets say we have 3 items and a user has selected all 3 items to buy. I need to lock the 3 items (meaning the other people who want to buy the same items cannot view it) for around 10 minutes. How do I implement this?

I am developing a Java web app using Hibernate and struts.

share|improve this question
add comment

1 Answer

I wouldnt lock them at all. Double check at checkout that they are available, and display a message if someone had bought the last one before the buyer checked out. I suspect a fairly high % of items are placed into a cart and never checked out. Depending on the nature of the site it could mean lost sales.

If you really do want to reserve the items, you might track a 'in cart' total for each item. Increment the 'in cart' field by 3 when 3 are added to a cart, and then after 10 minutes (or when a sale is made) remove them. Only show items where 'total inventory' - 'in cart' are greater than zero.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.