I am posting this again, the last time the formatting got kinda munged:

 

I am trying to set up an inventory/ticket purchasing system.  I have a table
that stores the available quantity, and I have a form where users can
purchase tickets. The form shows the current number of available tickets.  I
have another table that I am using to hold pre-authorizations that
essentially 'hold' a specific quantity while the purchase is complete.

Because the purchase may involve a trip to payPal, I need to be able to
lookup the pre-authorized amount when I get the callback from Paypal and
either commit that amount on success or release it on failure.

 

Does this rough outline make sense? Can I use a named lock in this fashion
to lock to separate pieces of code to ensure they are single threaded?

 

 

1.       User submits the form

 

START EXCLUSIVE NAMED LOCK ('TICKETPURCHASE'):    

 

                            i.      Get Available ticket quantity + any
pending pre-authorizations to purchase.

 

                            ii.      If the number available - number of
purchases pending > 0, then add an entry to the pre-auth table to the
requested quantity for the current purchaser

 

 

            END EXCLUSIVE NAMED LOCK ('TICKETPURCHASE')

 

2.       Process credit card

 

 

               a.       ON SUCCESS

 

START EXCLUSIVE NAMED LOCK ('TICKETPURCHASE')

 

1.           Get pre-auth record, update available ticket quantity table

(essentially committing the pre authorized items

 

2.       Delete pre-auth record

 

                             ENDEXCLUSIVE NAMED LOCK ('TICKETPURCHASE')

 

 

b.      ON FAILURE

START EXCLUSIVE NAMED LOCK ('TICKETPURCHASE')

1.       Delete pre-auth record

END EXCLUSIVE NAMED LOCK ('TICKETPURCHASE')

 

 

Will a system like this work?

Brook

 

 




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:344488
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to