Ensures the integrity of shared data. Instantiates the
following kinds of locks:

* Exclusive allows single-thread access to the CFML constructs
* Read-only allows multiple requests to access CFML constructs

 <cflock name="lockName" timeout="3">

 lock name="lockName" timeout="3" { }

cflock Attribute Reference


Maximum length of time, in seconds, to wait to obtain a
lock. If lock is obtained, tag execution continues.
Otherwise, behavior depends on throwOnTimeout attribute


Lock scope. Mutually exclusive with the name attribute.
Lock name. Only one request in the specified scope can
execute the code within this tag (or within any other
cflock tag with the same lock scope scope) at a time. Values:
  • Application
  • request
  • Server
  • Session


Lock name. Mutually exclusive with the scope attribute.
Only one request can execute the code within a cflock tag
with a given name at a time. Cannot be an empty string.

Default: YES

How timeout conditions are handled.

Default: exclusive

readOnly: lets more than one request read shared data.
exclusive: lets one request read or write shared data. Values:
  • readonly
  • exclusive

Examples sample code using the cflock tag

Script Syntax

lock timeout="60" scope="session" type="exclusive" { 
 session.myVar = "Hello"; 

Tag Syntax

<cflock timeout="60" scope="session" type="exclusive"> 
 <cfset session.myVar = "Hello"> 

Fork me on GitHub