Coldfusion Persistent Variable Issues - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Note: Although you can use 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
the Session, or Application scope clears the entire scope, including the built-in variables. Using the
function to clear the Client scope clears the variables from the server memory, but does
StructClear
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
client identity information in a clustered environment" on page
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
StructClear
function to clear your data from the Server scope, the
StructClear
321.
"Locking code with cflock" on page
About persistent scope variables
function to clear
"Managing
333.
317

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents