Why not?
lock
cfset application.myCachedData =
CreateObject('component','ThisHereObj').init()
/lock
If this should run only once, you could check to see if
application.myCachedData is defined and only initialize if it isn't. How
would that work?
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Bryan F. Hogan
> Sent: Thursday, October 16, 2003 5:24 PM
> To: [EMAIL PROTECTED]
> Subject: [CFCDev] Initialize only once
>
>
> 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].XMLChildr
> en[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]
----------------------------------------------------------
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]