Hi Ryan, I use server/application/session/custom etc but move them to the request scope for each request so that I can change where how I store those variables whilst the hundreds of pages referencing them are agnostic to their source.
except for simple/array values these request variables are just *pointers* to the the application/session/custom variables and since these are constants updating/locking is not an issue. Elliot "Ryan Sabir" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Hi all, > > I'm just having a think about the best way to set global constants for > my applications, these are things like datasource names and passwords, > upload directories etc... as far as I know there are a few ways to set > these up, these being: > > * Setting variables in the Application.cfm file > e.g. in the Application.cfm file I have a bunch of lines like > <CFSET dsName = "mydsn"> > <CFSET dsUser = "theuser"> > <CFSET dsPass = "thepass"> > > then throughout my app, I have lines like: > <cfquery username="#dsUser#" password="#dsPass#" name="qName" datasource="#dsName#"> > > * Setting session variables > e.g. in the Application.cfm file I have a bunch of lines like > <CFLOCK blah> > <CFIF not isDefined("session.dsName")> > <CFSET session.dsName = "mydsn"> > <CFSET session.dsUser = "theuser"> > <CFSET session.dsPass = "thepass"> > </cfif> > <CFSET session_dsName = "mydsn"> > <CFSET session_dsUser = "theuser"> > <CFSET session_dsPass = "thepass"> > </CFLOCK> > > then throughout my app, I have lines like: > <cfquery username="#session_dsUser#" password="#session_dsPass#" > name="qName" datasource="#session_dsName#"> > > * Setting application variables > Same as session variables, but using the application scope with the > required locks around it. > > Now of all the methods above, which is the most efficient and fastest? > The dumbest way looks like the first method where you are setting > request scope variables every time any page is called... but the other > methods involve overhead with locking variables whenever they are > read. > > Is there a best practice for this type of this? > > bye! > > ----------------------- > Ryan Sabir > Newgency Pty Ltd > 2a Broughton St > Paddington 2021 > Sydney, Australia > Ph (02) 9331 2133 > Fax (02) 9331 5199 > Mobile: 0411 512 454 > http://www.newgency.com/index.cfm?referer=rysig > > > --- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/
