Ahh .. my thinking was to try to avoid having to set a variable on every
single page and just store something like the DSN that is used frequently in
a memory variable. After reading your comments, and in hindsight, I suppose
it's a lot easier on system resources to simply set the variable instead of
having to lock it all over the place. Also, moving the memory variable to a
local one before use defeats the purpose of having the memory variable to
begin with, so ...
Guess I'll do a little rewriting :)
Thanks.
Todd Ashworth
| > Is it necessary to lock session variables while doing a
| > StructDelete() on them?
|
| Yes.
|
| > Also .. say one is reading or writing a Session variable and
| > an Application variable in the same line of code. What scope
| > would one use on the lock if one couldn't get an individual
| > lock around each variable?
| >
| > <cfif not IsDefined('Session.Variable') or not
| > Len(Trim('Application.Variable'))>
| > blah blah blah
| > </cfif>
|
| If you've got things within two different scopes which need to be locked,
| you'll need two separate locks. Neither scope is a subset of the other. If
| you have to, you can copy variables from a memory scope to a local scope
| before you use them.
|
| > Also .. is nesting locks a bad idea? For example:
| >
| > <cfquery name="qryQuery" datasource="#Application.DSN#">
| > SELECT blah, blah2, blah3
| > FROM this_table
| > WHERE table_id = #Session.TableID#
| > </cfquery>
| >
| > Is this the only way to do it?
| >
| > <cflock scope="Application" timeout="10" type="ReadOnly">
| > <cfquery name="qryQuery" datasource="#Application.DSN#">
| > SELECT blah, blah2, blah3
| > FROM this_table
| > WHERE table_id = <cflock scope="Session" timeout="10"
| > type="ReadOnly">
| > #Session.TableID#
| > </cflock>
| > </cfquery>
| > </cflock>
| >
| > That seems awfully inefficient.
|
| No, there are other ways to do this.
|
| Again, you can copy variables to a local scope before using them. This
will
| keep you from having to use nested locks.
|
| Also, you can rethink your use of memory variables, and limit it to what
you
| really need to keep in memory. For example, for things like the datasource
| name, what you really want is a constant. CF doesn't have anything which
is
| directly analogous to constants; I like to use the Request scope for
| constants, though, as it's not stored in memory and avoids the need for
| locking.
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message
with 'unsubscribe' in the body to [EMAIL PROTECTED]