User Guide
cflock 221
cflock
Description
Ensures the integrity of shared data. Instantiates the following kinds of locks:
• Exclusive allows single-thread access to the CFML constructs in its body. The tag body can
be executed by one request at a time. No other requests can start executing code within the tag
while a request has an exclusive lock. ColdFusion issues exclusive locks on a first-come,
first-served basis.
• Read-only allows multiple requests to access CFML constructs within the tag body
concurrently. Use a read-only lock only when shared data is read and not modified. If another
request has an exclusive lock on shared data, the new request waits for the exclusive lock to be
released.
Category
Application framework tags
Syntax
<cflock
timeout = "timeout in seconds "
scope = "Application" or "Server" or "Session"
name = "lockname"
throwOnTimeout = "Yes" or "No"
type = "readOnly" or "exclusive ">
<!--- CFML to be synchronized --->
</cflock>
See also
cfapplication, cfassociate, cfmodule,
Chapter 15, “Using Persistent Data and Locking,”
in Developing ColdFusion MX Applications
Attributes
Attribute Req/Opt Default Description
timeout Required 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
value.
scope Optional 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.
• Application
• Server
• Session
name Optional 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.
Permits synchronizing access to resources from different
parts of an application. Lock names are global to a
ColdFusion server. They are shared among applications
and user sessions, but not clustered servers.