Thanks for the tips...it was educational! - Kinley

>From: "gyrus" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: CF-Talk <[EMAIL PROTECTED]>
>Subject: Re: Request Scope Questions
>Date: Sun, 11 Nov 2001 03:59:32 -0000
>
> > I've been trying to brush up on my CF skills and I'm a bit confused with
> >  Request Variables.
>
>The request scope lasts for the duration of each request. If
>you define request.var, every file (includes, custom tags,
>whatever) that's processed from then on in the course of
>that HTTP request has access to request.var.
>
>Session variables persist for as long as the session timeout
>(set in CF Admin or <cfapplication> tag), and are specific to each
>client. Application variables' persistence are again controlled
>by CF Admin or <cfapplication> settings, and are specific to each
>application (as defined with the <cfapplication> tag).
>
>Both session and application variables (and server variables)
>need to be locked when read or written to. Check out
>
>ColdFusion Locking Best Practices
>http://www.allaire.com/Handlers/index.cfm?ID=17318
>
>Locking in ColdFusion
>http://www.allaire.com/handlers/index.cfm?ID=17196
>
>To Lock or Not To Lock
>http://www.defusion.com/articles/index.cfm?ArticleID=105
>
>for different views of locking. I found these articles kind of confusing
>when taken together, each has a different angle. But you should
>gain something between them. I don't understand the technicalities of
>locking, but as I understand it the risk of clashes in CF accessing
>application/session/server variables is due to how they are stored
>in memory. There's the risk of memory leaks if there's a clash here.
>The request scope is treated differently and doesn't carry that
>risk (wow, listen to the tech jargon! ;) and hence you don't need
>to put a lock around each time a request variable is written to or
>read from.
>
>Request variables are often talked of just in the context of custom
>tags, cos the fact that they can be accessed from anywhere
>during one request means they're useful for custom tags to
>talk to each other. But I use them quite a bit. I set all stuff
>like DSN names and passwords in application.cfm using the
>request scope. Also, any session variables that are needed
>frequently, I transfer them to the request scope in application.cfm.
>That way, I put one lock around this chunk of 'transfer' code,
>and don't need to lock every time a session variable is needed.
>
>A couple of notes here: if you do this, use something like
>
><cfset request.var=Duplicate(session.var)>
>
>to transfer the variable. If you don't use Duplicate() - correct
>me if I'm wrong someone! - then request.var just becomes a
>'pointer' to session.var, and session.var is still actually read when
>you refer later to request.var (rendering the whole business kind
>of redundant!). Duplicate() - which is only available in CF4.5+ -
>makes request.var a 'deep' copy of session.var, and then
>request.var technically has nothing to do with session.var
>except having the same value.
>
>Also, I think the 'scope' attribute of <cflock> is new in 4.5 (one
>of those articles above explains how to use it). Use it!
>
>I think there was a recent thread about how this kind of practice
>affects processing speed. I haven't yet done any really high-traffic
>sites where this might be a concern, so the convenience of the
>request scope is great, for now.
>
>hth,
>
>- Gyrus
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to