Good morning all, I have the following code that reads from a configuration
file. I only want this function to read once and then cache the data within
the component. Outside of caching the component itself is there a way to
cache the data within the component?

<cfset init()>

<cffunction name="init" access="public" returntype="struct" output="false">

        <cfset var initReturn=structNew()>
        <cfset var objXML=''>
        <cfset var idx=1>

        <cffile action="read" charset="utf-8"
                file="#ReplaceNoCase(getCurrentTemplatePath(),
ListLast(getCurrentTemplatePath(), '\'), 'config.xml')#"
                variable="objXML">

        <cfset objXML=XMLParse(objXML)>
        <cfset objXML=XMLSearch(objXML, '/config/')>

        <cfloop from="1" to="#ArrayLen(objXML[1].XMLChildren)#" index="idx">
                <cfset
initReturn[objXML[1].XMLChildren[idx].XMLName]=objXML[1].XMLChildren[idx].XM
LText>
        </cfloop>

        <cfreturn initReturn>
</cffunction>


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to