or you can do

<cflock name="appvars" type="exclusive" timeout="5" throwontimeout="yes">
        <cfscript>
                application.myVar = "this is a test";
                application.myVar2 = "this is also a test";
                application.foo = "bar";
        </cfscript>
</cflock>

If you bench mark these calls, you do find out that naming the lock when
accessing APPLICATION vars is more efficient, rather than using the
scope="application".  If you choose to do this though, make sure you re-use
the same lock name when you access all application references, including
READ locks, otherwise you run into issues.

<cflock name="appvars" type="readonly" timeout="5" throwontimeout="yes">
        <cfscript>
                myvar1 = application.myVar;
                myvar2 = application.myVar2;
                foobar = application.foo;
        </cfscript>
</cflock>       

Cheers,

Timothy Stadinski
Senior Software Engineer
Afternic.com

-----Original Message-----
From: Brent Goldman [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 07, 2001 7:45 PM
To: CF-Talk
Subject: RE: application variables


Hi Nick,

You need to specify the APPLICATION scope in your CFLOCK tag.  You should
put the following CFML around any other CFML that access the application
scope:

<cflock scope="application" type="exclusive" timeout="10">
        ...CFML...
</cflock>

-Brent

> -----Original Message-----
> From: Nick Le Mouton [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, November 07, 2001 4:33 PM
> To: CF-Talk
> Subject: application variables
>
>
> I have been told that when setting application variables it is good
> programming practice to put a cflock around them
>
> so on some of my pages in my application would i do the following?
>
> <cflock type="EXCLUSIVE" timeout="10">
>       <cfset application.something = "something">
> </cflock>
>
> Thanks
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
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