Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFLOCK question - When/how to use

Status
Not open for further replies.

johk02

Programmer
Aug 20, 2003
169
AU
Hi,

I have read up about how and when to use CFLOCK but still need some clarifications.

If I have some variables (request scope) in my application.cfm do I need CFLOCK around them?? Do I only need CFLOCK around application.var_name as they can be accessed through out the application??

If you put CFLOCK around queries i.e. insert, update and delete is the CFLOCK scope application or session and do I need to declare a name for the CFLOCK??

Thanks
Jonas

 
This article should help:

[URL unfurl="true"]http://www.macromedia.com/devnet/server_archive/articles/cf_locking_best_practices.html[/url]

Mainly you lock stuff that other people can get to. Other people can not get to a query running on a page, but other people can get to application and server variables.

Kris Brixon

If you're not failing every now and again, it's a sign you're not doing anything very innovative.
- W. Allen
 
I thought one of the Macromedia articles stated that If you use application scoped variables to store things one time, like settings, dsn, etc, and only wrote those vars if they did not exists, then you didn't need to lock subsequent writes.

in application.cfm

<cflock scope="application" exclusive. ...>

<cfif NOT structKeyexists(application,"isReady")>
<cfset application.dsn = "myDSN">
<cfset application.isReady = true>
</cfif>

</cflock>

So it only gets written once, during the initialization of the application scope.

then when you use those vars, it is safe to simply call #application.dsn#



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top