1

I am new to web development and I've decided to implement concurrency in a Cinema ticketing website. So for example, when a customer selects a seat, I would like to lock the seat temporarily, rather than get interference from other customer, or avoid the scenario where two customers select the seat at the same time.

The scripting language and database I have chosen to develop this website are PHP, Javascript and MySQL.

Please give some suggestions or links about what technique I should use to fix it? Is that considered concurrency?

1
  • Ensure that your database engine of choice in MySQL supports transactions, and look at using MySQL EVENTS to release seat locks Commented Jan 26, 2012 at 11:55

1 Answer 1

1

This answer suggests a good way of doing this:

[...] create a column containting a timestamp. Whenever you want to lock the row you update it to the current time. To unlock update to a time at least x minutes in the past. Then to check if its locked check that the time stamp is at least x minutes old.

This way if the process crashes (or the user never completes their operation) the lock effectively expires after x minutes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.