Stormkid wrote:
Hi Group, I'm trying to figure out the best way to avoid the situation of
when two or more users access a record for a certain product around the
same time but say user1 sits and reads the documentation regarding the
product while in that time user2 comes along and buys the product and
clears the item out of stock and I'm wondering what approaches some of you
in the group
would take to avoid this situation. Thanks Storm
Hi Storm,
I can think of 2 solutions:
1) Just let user1 know he is in bad luck when he places the order.
This is by far the simplest solution, and the chances of this happing are
small I expect. Add some humor to it: "Sorry, the item is right out of
stock. Didn't we tell you to place your orders as quickly as possible?"
2) polling
The first solution is of course not a real solution.
If you want your clients (as in users using a browser) to be up to date,
they sould ask the server if the situation is still the same every minute
or so. (=polling).
This, of course, places a extra load on the server. And on you, the
programmer.
Probabaly a simple refresh of the screen will do.
If you think that is ugly, which it is, you have to resort to a hidden frame
or something like that for the polling and use javascript to decide if the
mainframe is still up to date.
If possible use 'solution' 1.
I expect people will understand that when they look at your product for one
hour (what the heck are you selling by the way??), it can be sold out in
that time.
:-)
Just my 2 cents..
Good luck and regards,
Erwin Moller