Administering the ColdFusion Server
|
|
Chapter 3 : Configuring ColdFusion Server
|
Locking Variables
Data stored in Server, Application and Session scopes ("shared data scopes") is persistent across browser requests and multiple requests can access the data. Unlocked access to data by multiple requests at the same time can corrupt the data. While you can still use the CFLOCK tag introduced in ColdFusion 4.0 to control simultaneous access to shared data in these scopes, ColdFusion 4.5 provides more automatic means to protect shared data from incorrect access.
For each of the Server, Application and Session scopes, the Variable Locking Administrator page provides three choices for control - none, full checking, and automatic locking of read accesses:
- Choosing "None" retains current ColdFusion behavior. All reads and writes of data must be protected by a CFLOCK tag. No automatic protection is provided and unprotected accesses may cause corruption of data.
- Choosing "Full checking" will cause ColdFusion to raise an error if any read or write of data in one of the scopes occurs outside of the scope of a CFLOCK. This includes accesses to any data that is aliased by being assigned to a variable outside of the shared data scopes and the data is not copied; this can occur for struct and query variables. For example:
<CFLOCK type="EXCLUSIVE" scope="Session" timeout="10">
<CFSet Session.var = StructNew() >
<CFSet myvar = Session.myvar>
</CFLOCK>
<CFSet myvar2 = myvar> <!--- unprotected access to alias --->
- Choosing "Automatic read locking" will cause ColdFusion to raise errors for unprotected writes, but unprotected reads will be automatically locked.
- For Session scope, you can also choose to single thread session requests. This means that all requests from the same session will occur sequentially, each request waiting for all previous requests to finish before proceeding, preventing multiple requests from simultaneously accessing shared data.
Copyright © 1999, Allaire Corporation. All rights reserved.
|
|