Using Cflock For Exclusive Locking - MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual

Developing web applications with coldfusion
Table of Contents

Advertisement

198
Example: Application.cfm
The following example shows a complete
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
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:
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.
Developing Web Applications with ColdFusion
file for the sample
Application.cfm

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 4.5

Table of Contents