> 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.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to