Depends on a lot of things - complexity of variables, how often they're
going to change, how many users you're expecting, how performance-critical
the app is, how long it takes to obtain the values that you're going to
store (e.g. if you're storing, say, a five-value array, but populating that
array takes twenty queries), etc. etc. etc.
Both are valid ways of doing it, I just always try to design data structures
in terms of what "feels" right, for instance, the Home directory of a site
"feels" more like a property of the application, rather than an individual
page request, so it goes in the application scope. Besides, if you use app.
scope to begin with, you've then got expansibility built in for that
horrible day whwn the client says "Great, that's just what I asked for, but
what I actually WANT is......"
-----Original Message-----
From: Daniel Lancelot [mailto:[EMAIL PROTECTED]]
Sent: 29 May 2001 15:37
To: CF-Talk
Subject: RE: Request vs application scope
But using request vars means the memory is released immediately the request
has finished...
I would agree if you are planning to store large/complex data (esp query
result sets etc) then its probably best to use app scope...
But would you consider it best if there are just a few simple vars (maybe
100B)?
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: 29 May 2001 15:07
To: CF-Talk
Subject: RE: Request vs application scope
That's the downside! Also, they are unique to each request, so memory &
processor usage will increase by a set amount for each page request.
e.g.
APPLICATION scope
--------------------
<cflock scope="APPLICATION" .....>
<cfif NOT IsDefined( "APPLICATION.TestVar" )>
<!--- Set up (say) 2KB of application variables --->
</cfif>
</cflock>
- First request, you get a CPU performance hit while you set up the app.
variables, and 2KB of memory is taken up by the variables.
- Subsequent requests will detect the existence of APPLICATION.TestVar, and
not bother setting the variables up again.
- Total memory usage - 2KB for the application variables, however many page
requests are made.
REQUEST scope
-------------
<cfset REQUEST.(whatever) = (whatever)>
......
......
......
<!--- set up the same 2KB of variables in the request scope --->
- Every single request will use the CPU while setting up the variables, and
need the 2KB of memory for itself.
- If you're in a frameset, that's (say) 3 times the CPU usage and an extra
4KB of memory per client, per hit.
- Total memory usage - 2KB * number of frames * number of simultaneous
users.
If you're using the scope to store queries or other complex objects, or even
long strings, you're going to end up with a fairly hefty performance hit.
Alistair Davidson
Senior Developer
Rocom New Media
www.rocomx.net
-----Original Message-----
From: Steve Vosloo [mailto:[EMAIL PROTECTED]]
Sent: 29 May 2001 14:43
To: CF-Talk
Subject: RE: Request vs application scope
Brilliant! So what's the downside? The variables are not persistent across
pages are they?
> -----Original Message-----
> From: Daniel Lancelot [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 2:56 PM
> To: CF-Talk
> Subject: RE: Request vs application scope
>
>
> Yes thats right.
>
> -----Original Message-----
> From: Steve Vosloo [mailto:[EMAIL PROTECTED]]
> Sent: 29 May 2001 13:51
> To: CF-Talk
> Subject: RE: Request vs application scope
>
>
> Thanks.
>
> Can I put any data in there that I want to use across the site?
> And I don't
> have to apply CFLOCKs do I?
>
>
>
> > -----Original Message-----
> > From: Daniel Lancelot [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, May 29, 2001 2:32 PM
> > To: CF-Talk
> > Subject: RE: Request vs application scope
> >
> >
> > Absolutely no problem... I do it regularly...
> >
> > -----Original Message-----
> > From: Steve Vosloo [mailto:[EMAIL PROTECTED]]
> > Sent: 29 May 2001 08:34
> > To: CF-Talk
> > Subject: Request vs application scope
> >
> >
> > I am using the following line of code in my application.cfm
> >
> > <cfset request.HomeDir = "http://127.0.0.1/work/ACME/may2001/website">
> >
> > Then elsewhere in the site I refer all links and images to:
> >
> > <cfoutput>#request.HomeDir#</cfoutput>
> >
> > Is this OK to do? I'm trying to avoid using the application
> > scope. Are there
> > any known of issues with this method?
> >
> > Thanks.
> > Steve
> >
> >
> >
> >
> >
> > Development Manager
> > Vardus Internet Solutions (SA)
> >
> > Tel: (+27) 21 670 9880
> > Fax: (+27) 21 674 4549
> >
> > Email: [EMAIL PROTECTED]
> > Website: www.vardus.com
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists