198
Developing Web Applications with ColdFusion
Example: Application.cfm
The following example shows a complete
Application.cfm
file for the sample
Products application:
<!--- Set application name and enable client
variables option, with client variables stored in
a data source called mycompany --->
<CFAPPLICATION NAME="Products"
CLIENTMANAGEMENT="Yes"
CLIENTSTORAGE="mycompany">
<!--- Install custom error pages --->
<CFERROR TYPE="REQUEST"
TEMPLATE="requesterr.cfm"
MAILTO="admin@company.com">
<CFERROR TYPE="VALIDATION"
TEMPLATE="validationerr.cfm">
<!--- Set application constants --->
<CFSET HomePage="http://www.mycompany.com">
<CFSET PrimaryDataSource="CompanyDB">
Using CFLOCK for Exclusive Locking
The CFLOCK tag provides a means of implementing exclusive locking in ColdFusion
applications. The reasons you use CFLOCK include :
•
Protecting sections of code that manipulate shared data, such as session,
application, and server variables.
•
Ensuring that file updates do not fail because files are open for writing by other
applications or ColdFusion tags.
Note
Use anonymous locks to protect a portion of a template, for example a
non-thread safe CFX. Use named locks to prevent parallel access to data.
How CFLOCK works
The CFLOCK tag can single-thread access to the CFML constructs in its body, so that
the body of the tag can be executed by at most one request at a time. By default, a
request executing inside a CFLOCK tag has an "exclusive lock" on the tag. No other
requests are allowed to start executing inside the tag while a request has an exclusive
lock. ColdFusion issues exclusive locks on a first-come first-serve basis.
However, ColdFusion offers provisions for allowing read-only access to locked code.
The CFLOCK tag offers two modes of locking:
Summary of Contents for COLDFUSION 4.5-DEVELOPING WEB
Page 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Page 14: ...xiv Developing Web Applications with ColdFusion...
Page 26: ...xxvi Developing Web Applications with ColdFusion...
Page 34: ...8 Developing Web Applications with ColdFusion...
Page 70: ...44 Developing Web Applications with ColdFusion...
Page 84: ...58 Developing Web Applications with ColdFusion...
Page 114: ...88 Developing Web Applications with ColdFusion...
Page 148: ...122 Developing Web Applications with ColdFusion...
Page 174: ...148 Developing Web Applications with ColdFusion...
Page 208: ...182 Developing Web Applications with ColdFusion...
Page 244: ...218 Developing Web Applications with ColdFusion...
Page 274: ...248 Developing Web Applications with ColdFusion...
Page 288: ...262 Developing Web Applications with ColdFusion...
Page 300: ...274 Developing Web Applications with ColdFusion...
Page 350: ...324 Developing Web Applications with ColdFusion...
Page 362: ...336 Developing Web Applications with ColdFusion...