----- Original Message -----
From: "Bud" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Sunday, June 23, 2002 11:07 PM
Subject: Exclusive Lock timeout question
> My question is, if I set a timeout value of "10" on an exclusive
> lock, what exactly times out?
>
> Is it...
> A) The person waiting for the lock will receive an error after
> waiting for 10 seconds?
If throwontimeout is set, yes.
> B) The person using the lock will receive an error if the code inside
> the lock runs for more than 10 seconds?
No
> C) Both?
No
Coldfusion will attempt to get the lock for 10 seconds, if it gets the lock
inside 10 seconds it will enter the locked portion of code and continue on
as normal. If it doesn't get the lock it will either (depending on what you
set throwontimeout to do) throw an error or continue from the first
statement after the locked portion of code.
> Or is there a better way to do this in anyone's opinion.
Perhaps you shoudl use CFTRANSACTION, it will "atomize" the individual
queries ... that is...
you have an available quantity, say 5, and 2 customers
customer one comes in he wants 3 items, and customer 2 comes in he wants 3
items, your code is
<CFTRANSACTION>
<CFQUERY>
get number of available items
</CFQUERY>
<CFIF enough items available>
<CFQUERY>
reduce number of items
</CFQUERY>
<CFELSE>
Say "not enough items"
</CFIF>
</CFTRANSACTION>
all the queries between the <CFRANSACTION> tags will for all intents and
purposes happen simultaneously, that is, for customer one (assuming they got
into the CFTRANSACTION first) they will get the number of available items,
and set the reduced number _at the same time_. Customer 2 will then get
reign over the CFTRANSACTION and they will get the new number of available.
Think of it as an exclusive lock that the database will handle for you, nice
and easy.
---
James Sleeman
Innovative Media Ltd
Ph: (03) 377 6262
http://www.websolutions.co.nz
CAUTION: The information contained in this email message is confidential
and may be legally privileged. If the reader of this message is not the
intended recipient you are notified that any use, dissemination,
distribution or reproduction of this message is prohibited. If you have
received this message in error please notify the sender immediately and
destroy the original message and any attachments.
Views expressed in this communication may not be those of Innovative Media
Ltd.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.372 / Virus Database: 207 - Release Date: 6/20/2002
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists