About persistent scope variables
317
Note:
Although you can use the
StructClear
function to clear your data from the Server scope, the
function does not delete the names of the variables, only their values, and it does not delete the
contents of the Server.os and Server.ColdFusion structures. Using the
StructClear
function to clear
the Session, or Application scope clears the entire scope, including the built-in variables. Using the
StructClear
function to clear the Client scope clears the variables from the server memory, but does
not delete the stored copies of the variables.
ColdFusion persistent variable issues
Variables in the Session, Application, and Server scopes are kept in ColdFusion server memory.
This storage method has several implications:
•
All variables in these scopes are lost if the server stops running.
•
Variables in these scopes are not shared by servers in a cluster.
•
To ensure data consistency, you must lock access to all code that changes variables in these
scopes and all code that reads variables in these scopes with values that can change.
Additionally, you must be careful when using client variables in a server cluster, where an
applications can run on multiple servers.
Note:
If you use J2EE session management and configure the J2EE server to retain session data
between server restarts, ColdFusion retains session variables between server restarts.
Using variables in clustered systems
Because memory variables are stored in memory, they are not available to all servers in a cluster.
As a result, you generally do not use Session, Application, or Server scope variables in clustered
environment. However, you might use these scope variables in a clustered system in the following
circumstances:
•
Many clustering systems, including ClusterCats support “sticky” sessions, in which the
clustering system ensures that each user session remains on a single server. In this case, you can
use session variables as you would on a single server.
•
You can use Application and Server scope variables in a cluster for write-once variables that are
consistently set, for example, from a database.
To use client variables on a clustered system, store the variables as cookies or in a database that is
available to all servers. If you use database storage, select the Purge Data for Clients that Remain
Unvisited option in the ColdFusion MX Administrator Client Variables Add/Edit Client Store
page on one server only.
For more information on using client and session variables in clustered systems, see
“Managing
client identity information in a clustered environment” on page 321
.
Locking memory variables
Because ColdFusion is a multithreaded system in which multiple requests can share Session,
Application, and Server scope variables, it is possible for two or more requests to try to access and
modify data at the same time. ColdFusion runs in a J2EE environment, which prevents
simultaneous data access, so multiple requests do not cause severe system errors. However, such
requests can result in inconsistent data values, particularly when a page might change more than
one variable.
To prevent data errors with session, application, and server variables, lock code that writes and
reads data in these scopes. For more information, see
“Locking code with cflock” on page 333
.
Содержание COLDFUSION MX 61-DEVELOPING COLDFUSION MX
Страница 1: ...Developing ColdFusion MX Applications...
Страница 22: ...22 Contents...
Страница 38: ......
Страница 52: ...52 Chapter 2 Elements of CFML...
Страница 162: ......
Страница 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Страница 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Страница 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Страница 266: ......
Страница 314: ...314 Chapter 14 Handling Errors...
Страница 344: ...344 Chapter 15 Using Persistent Data and Locking...
Страница 349: ...About user security 349...
Страница 357: ...Security scenarios 357...
Страница 370: ...370 Chapter 16 Securing Applications...
Страница 388: ...388 Chapter 17 Developing Globalized Applications...
Страница 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Страница 410: ......
Страница 426: ...426 Chapter 19 Introduction to Databases and SQL...
Страница 476: ...476 Chapter 22 Using Query of Queries...
Страница 534: ...534 Chapter 24 Building a Search Interface...
Страница 556: ...556 Chapter 25 Using Verity Search Expressions...
Страница 558: ......
Страница 582: ...582 Chapter 26 Retrieving and Formatting Data...
Страница 668: ......
Страница 734: ...734 Chapter 32 Using Web Services...
Страница 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Страница 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Страница 788: ......
Страница 806: ...806 Chapter 35 Sending and Receiving E Mail...