[thelist] CF -- have a Q need a Tip to clean-up my webs.

.jeff jeff at members.evolt.org
Mon Oct 15 12:16:56 CDT 2001


rory,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Rory.Plaire at wahchang.com
>
> So, a further dissection? If assigning a query to a
> session scoped variable is A Good Thing, [...]
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

it is, provided you have a mechanism that makes sure the query only runs if
it isn't in memory.

<cflock scope="session" type="exclusive" timeout="10" throwontimeout="no">
  <cfparam name="session.myqry" default="">
  <cfif NOT IsQuery(session.myqry)>
    <cfquery name="myqry" ...>
      SELECT foo
        FROM bar
       WHERE bones <> 'ice cream'
    </cfquery>
    <cfset session.myqry = Duplicate(myqry)>
  </cfif>
</cflock>

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> then shouldn't I see code that wraps the access of the
> local variable to which it is assigned in a cflock?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

yes, you should see that.  there are spots in the docs that are not good
about locking.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Perhaps the assignment to a local variable?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

perhaps your problem is that you're not assigning a simple value to the
local variable, but a query which is a complex value and therefore gets
copied by reference rather than by value?  try the Duplicate() function
instead.

<cflock scope="session" type="readonly" timeout="10" throwontimeout="no">
  <cfset myqry = Duplicate(session.myqry)>
</cflock>

good luck,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/






More information about the thelist mailing list