Sorry, I meant to say "should" lock them :-p






Neil Clark
Team Macromedia
http://www.macromedia.com/go/team

Announcing Macromedia MX!! 
http://www.macromedia.com/software/trial/




-----Original Message-----
From: Shawn Regan [mailto:[EMAIL PROTECTED]] 
Sent: 26 June 2002 16:33
To: CF-Talk
Subject: RE: What is the best variable scope?

I usually only use the application scope for set variables that do not
change. So there are only being read, Maybe I will look at locking those
too, since two people could read the same variable at the same time. 

But I don't see any problems with not locking if the variable is only
going
to be read.

Shawn Regan

-----Original Message-----
From: Andrew Scott [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 26, 2002 7:36 AM
To: CF-Talk
Subject: RE: What is the best variable scope?


Shared variables such as application and session should be locked,
however the lock really only needs to be there on a write. Writing to a
shared variable can cause the system to hang or enter a state of
confusion, hence the locking of the variable.

However although recommended to lock all reads and writes, I personally
have never done it on a read of said such variables. It is also very
safe to do the following...

<cflock>
 <cfset application.test = "Test">
 <cfoutput>Hello</cfoutput>
</cflock>

All it means is that while this bit of code is being run, nobody else
can access this bit of code until this process has released the lock. If
2 applications write to a variable at the exact same time (rare, but
very possible) CF can enter a state of deadlock and will require the
server to be restarted.

For more information on this, consult the manual about the attributes
scope and type that allow the variable to be read only or exclusive and
to define the type of variable it is. For example is it an application,
server or even session scope.

But the point is well within what has been discussed many times on this
list, should we or should we lock reading of variables. Like I said I
don't when reading them, and have never had any problems (touch wood)
with this method.

But there are many reasons why one should use application scope
variables, for example to determine how many people are actually logged
into a membership system as a good example.
 


-----Original Message-----
From: Shawn Regan [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, 27 June 2002 12:18 AM
To: CF-Talk
Subject: RE: What is the best variable scope?

Why do you need to lock it?

Shawn Regan




______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to