> In my application.cfm I set a session var for all my queries' 
> datasource like this:
> 
> <cflock scope="session" timeout="30" type="exclusive">
>  <cfset session.ds = "something_dev">
> </cflock>
> 
> So... Do I need to read-only lock every reference to 
> session.ds in all my other templates where I have a query 
> using that datasource session var? e.g.,
> 
> <cfquery name="get_year" datasource=#session.ds#>
> select sysdate from dual
> </cfquery>
> 
> Since session.ds is always identical for every user of this 
> site, what does it matter if it's locked or not?

The short answer is, yes, you should lock it, because there's a potential
for memory corruption with multiple concurrent reads, which can occur even
with session variables.

The longer answer is that if the value is going to be the same for everybody
using the application, you should store it as a "constant" by putting it
into the local Variables scope within application.cfm, or even better, the
Request scope:

<cfset Request.ds = "something_dev">

There's no reason to store this on a per-user basis in memory unless each
user actually gets a different datasource.

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]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to