If I'm writing a ticketing system, where the customer selects the ticket and I want to lock it for 3 minutes (like ticket master) until they complete their order or time runs out, how could I do this? I want to avoid having a customer abandon their session/application crash and then end up with the ticket locked in the database forever.
I'm using nHibernate for my ORM and C#.
Just have a separate table that holds all current reservations. For example:
**Reservations**
UserID
TicketID
ExpiryDate
This will then not be dependant on sessions. You don't even need to delete expired records, when a new customer queries a ticket find all seats that are available where they dont exist in the reservations table where the expirydate > now.
Avoid more complex systems of timed events and things like that, keep it simple.