238
5
6
Note
You can skip any pair of lock/unlock steps in the preceding list if you do not need to
lock a particular scope. For example, you can omit steps 3 and 4 if you do not need to
lock the Server scope.
Examples of cflock
The following examples show how to use
Example with Application, Server, and Session variables
This example shows how you can use
updates to variables in the Application, Server, and Session scopes.
This example does not handle exceptions that arise if a lock times out. As a result,
users see the default exception error page on lock timeouts.
The following sample code might be part of the Application.cfm file:
<cfapplication name="ETurtle"
<!--- Initialize the session and application
variables that will be used by E-Turtleneck. Use
the session lock scope for the Session variables. --->
<cflock scope="Session"
</cflock>
<!--- Use the application lock for the
Application variable. This variable keeps
track of the total number of turtlenecks sold.
use the application lock scope for application variables. --->
<cflock scope="Application"
Unlock the Application scope.
Unlock the Session scope.
sessiontimeout=#createtimespan(0,1,30,0)#
sessionmanagement="yes">
timeout="10" type ="Exclusive">
<cfif not isdefined("session.size")>
<cfset session.size = "">
</cfif>
<cfif not isdefined("session.color")>
<cfset session.color = "">
</cfif>
timeout="10"
type="Exclusive">
<cfif not isdefined("application.number")>
<cfset application.number = 1>
Chapter 12 Using the Application Framework
in a variety of situations.
cflock
to guarantee the consistency of data
cflock
Need help?
Do you have a question about the COLDFUSION 5-DEVELOPING and is the answer not in the manual?
Questions and answers