My usual method of locking CF Session variables:

Usually the idea of locking down an entire page scares me especially if it's
a huge action page.  Then I remembered the order of Scope resolution being
that Local Variables resolve before session variables.  So rather than set
up a CFLOCK over an entire page, I just do something like this

<CFLOCK>
<CFSET A=Session.A>
</CFLOCK>

<CF_RestofAction>

Then I proceed to use those local variables inside the page.  Integrity
should be perfectly ok granted local variables don't get confused. Even
though the extra CFSET statements add some time, it sure beats locking the
whole page up.  This is certainly recommended for larger action pages
granted the CFLOCK will really tie things up.

Gregory Harris
Web Developer
Stirling Bridge Group LLC

----- Original Message -----
From: "Dave Watts" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, December 21, 2000 10:11 AM
Subject: RE: LOCKING revisited...


> > Ok, given that we all agree:
> >
> > ** Access to shared variables should *ALWAYS* be locked **
> >
> > Then why on Earth shouldn't I just turn on Automatic Read
> > Locking for Application (and Session et al if I use them)
> > scope and only worry about write locking in my code?
> >
> > Why doesn't everyone do that, with the rare exception of some
> > code that has unusual locking needs.
> >
> > I've heard the argument that automatic read locking is a
> > slight performance hit. It couldn't be more of a hit than
> > parsing <cflock> </cflock> around every access and still
> > doing the read lock anyway!
>
> That's certainly an alternative. However, I'd argue that you want to write
> the code so that, all other things being equal, that code is safe. You
> might, for example, not have control over server configuration, or you
might
> be writing a shrinkwrap application.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
> voice: (202) 797-5496
> fax: (202) 797-5444
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to