Hey Guys,
I recently choose .ini files to store user defined application
variables in. I will be grabbing the variables I need throughout my
application with the getprofilestring and getprofilessection
functions.
***Should I be caching the values I store in the ini files somehow? In
my head I assume getprofilestring could be an expensive operation
since it needs to read the value from the file stored on the hard
drive.
***If I wanted to cache the values in the application scope is there a
good way to detect if the .ini file has been modified and only then
reload the cache?
This may not be something I have to worry about, but I just want to
make sure I am using best practices. I also don't expect my user
defined application variables to change very often after the initial
configuration.
Below is an example of how I will be using the settings defined in the
ini in my application's logic. Please let me know what you think.
<cffunction name="index" output="false">
<cfset var l = {
publicPage: getprofilestring(application.basepath &
"/config/
settings.ini.cfm", "mainpage", "publicPage"),
forwardUrl:getprofilestring(application.basepath &
"/config/
settings.ini.cfm", "mainpage", "forwardUrl")
} />
<cfif structKeyExists(rc, "curl") AND len(rc.curl)>
<!--- push to url--->
<cfset
application.theFactory.getService("url").pushLongUrl(rc.curl) />
<cfelseif NOT l.publicPage>
<!--- forward to userdefined url--->
<cfif isValid('url', l.forwardUrl)>
<cfset location(l.forwardUrl, 'no') />
</cfif>
<cfabort />
<cfelse>
<!--- get main page --->
<cfset rc.title = "Main Page" />
</cfif>
</cffunction>
--
online documentation: http://openbd.org/manual/
google+ hints/tips: https://plus.google.com/115990347459711259462
http://groups.google.com/group/openbd?hl=en