doing it that way requires trips to the database for every request. the
whole point of using the application scope is to avoid this - especially for
large "lookup" type queries.

-----Original Message-----
From: Joe Bastian [mailto:[EMAIL PROTECTED]]
Sent: Saturday, July 13, 2002 2:51 PM
To: CF-Talk
Subject: RE: Storing Queries in Application Scope


Using the duplicate() arent you actually creating a DEEP "DUPLICATE" of the
structure.
So you have the query in "APPLICATION" scope and then in "REQUEST" scope...
taking
up MEMORY?
Why cant this just be done in the Request Scope and avoid LOCKING and
Structure duplicates?

<cfquery="Request.MyNewQuery" datasource="MyDB">
Select Field1, Field2 .. from MyTable
</cfquery>


Joe
Certified Advanced ColdFusion Developer
[EMAIL PROTECTED]

-----Original Message-----
From: S. Isaac Dealey [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 12, 2002 11:34 AM
To: CF-Talk
Subject: Re: Storing Queries in Application Scope


> No reason at all.
>
> Depending on your ColdFusion version:
>
> 1) You may want to investigate the use of ColdFusions built in query
> cacheing as well
>
> 2) Remember to lock all access to application scope variables.

I'm told that locking isn't necessary in CFMX although I expect it will be a
while yet before we can consider CF 5 the acception rather than the rule.

Speaking of which, if you're using application variables to store queries (
which I assume won't change often ), then you may really want to use a
construct like this:

<cflock scope="application" type="readonly" timeout="10">
<cfset request.queryname = duplicate(application.queryname)>
</cflock>

<select name="yadda">
        <cfoutput query="request.queryname">
                <option value="#request.queryname.column#">
                #request.queryname.column2#</option>
        </cfoutput>
</select>

The reason for this is that you generally want to limit the amount of code
within the cflock whether it's exclusive or read-only, because an exclusive
lock will still have to wait for all read-only locks to complete before it
can begin to process its code, and if your app is chock full of

<cflock scope="application">
<cfoutput
query="application.myreallylargequeryicachedintheapplicationscope">
 ... < .5kb of code designed to display something from my query > ...
</cfoutput></cflock>

Then your application is going to have a tough time creating exclusive locks
to set those application variables... Also, when you set a query into the
application scope in an exclusive lock, don't lock around the cfquery or
cfstoredproc tags ... draw the query locally, then use duplicate() to copy
it to the application scope, similar to or rather inverse of the example
above.

You may already know a lot of this, but I think the refresher is always
good. And hopefully this information may be helpful to some of the other
less experienced list members as well. :)

hth

Isaac Dealey
www.turnkey.to
954-776-0046


______________________________________________________________________
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/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to