A few things.

1) The lock isn't really necessary if you don't have any race conditions.
2) Why do you create a copy of application.IOFactory in the variables
scope? You don't need to normally. I'd just have code like so:

<cfif not isDefined("application.foo")>
  <cfset application.foo = createObject(etc)>
</cffi>

-Ray

On Thu, 22 Jul 2004 13:28:59 +0200, Micha Schopman
<[EMAIL PROTECTED]> wrote:
> Is this a correct way of caching a CFC, for future reuse and preventing
> useless IO traffic? I never tried this approach in production but I
> don't believe there are a lot of problems with this construction in
> terms of memory.
>
> <cfapplication name="persistencyTest" sessionmanagement="yes"
> clientmanagement="no">
>
> <cflock scope="application" type="exclusive" timeout="1">
>         <cfif NOT IsDefined('application.IOFactory')>
>                 <!--- loaded CFC into cache --->
>                 <cfset IOFactory =
> createObject('component','myfunction').init()>
>                 <cfset application.IOFactory = IOFactory>
>         <cfelse>
>                 <!--- loaded CFC from cache for reuse without re-calling
> the class --->
>                 <cfset IOFactory = application.IOFactory>
>         </cfif>
> </cflock>
>
> Micha Schopman
> Software Engineer
>
> Modern Media, Databankweg 12 M, 3821 AL  Amersfoort
> Tel 033-4535377, Fax 033-4535388
> KvK Amersfoort 39081679, Rabo 39.48.05.380
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to