Macromedia coldfusion 4.5-cfml language reference Benutzerhandbuch

Seite von 608
122
CFML Language Reference 
CFLOCK
The CFLOCK tag provides two types of locks to ensure the integrity of shared data:
exclusive lock
read-only lock
An exclusive lock single-threads access to the CFML constructs in its body. Single-
threaded access implies that the body of the tag can be executed by at most one 
request at a time. 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-served 
basis.
A read-only lock allows multiple requests to access the CFML constructs inside its 
body concurrently. Therefore, read-only locks should only be used when the shared 
data will only be read and not modified. If another request already has an exclusive 
lock on the shared data, the request will wait for the exclusive lock to be released 
before it can obtain it.
Syntax
<CFLOCK 
TIMEOUT="timeout in seconds "
SCOPE="Application" or "Server" or "Session"
NAME="lockname" 
THROWONTIMEOUT="Yes/No"
TYPE= "ReadOnly/Exclusive "> 
<!--- CFML to be synchronized ---> 
</CFLOCK>
TIMEOUT
Required. Specifies the maximum amount of time in seconds to wait to obtain an 
lock. If a lock can be obtained within the specified period, execution will continue 
inside the body of the tag. Otherwise, the behavior depends on the value of the 
THROWONTIMEOUT attribute.
SCOPE
Optional. Specifies the scope as one of the following: Application, Server, or 
Session. This attribute is mutually exclusive with the NAME attribute. See the 
Scope section for valuable information.
NAME
Optional. Specifies the name of the lock. Only one request will be able to execute 
inside a CFLOCK tag with a given name. Therefore, providing the NAME attribute 
allows for synchronizing access to the same resources from different parts of an 
application. Lock names are global to a ColdFusion server. They are shared 
between applications and user sessions, but not across clustered servers. This 
attribute is mutually exclusive with the SCOPE attribute. Therefore, do not specify 
the SCOPE attribute and the NAME attribute in the same tag. Note that the value 
of NAME cannot be an empty string.