I'm working on a plugin to reserve and pay for a seat at an event. I'd like to assign an id, a ticket number of some sorts, to each reservation, and I'd like the ids to be short and sequential. Starting at 1000, I would store the latest id in the user/data folder, and increment and save the id with each order.
Although the number of reservations would probably be very low (1 or 2 per day), there's always the slight chance of two people reserving at the same time. How do I avoid a situation whereby a reservation reads the latest id, before it had the chance to be incremented by the previous order? Is there a way?