I have been using application-cached CFCs for a while now with great
success.  You are certainly saving some overhead of instantiation -- which
can be the most expensive part of using CFCs.  I have not experienced any
problems, but the apps I've tried this in aren't under heavy load.  I think
Sean talked about using this technique in Macromedia.com, however, which
certainly gets fairly heavy traffic.

The obvious warning is to look out for the page context but, but if you are
following the rules of encapsulation so often preached on this list you
shouldn't run into that (and should one day soon not have to even think
about that either).

In some of my recent apps I have a series of "services" which are CFCs
cached in the application scope -- at instantiation I usually pass in a DSN
name if they are doing queries.  In some circumstances I am passing an
instance of one service to another service at instantiation -- this way I
can preserve encapsulation while taking advantage of one service inside
another service.

I've also had luck caching CFCs in the session scope.  In particular, I've
taken to having a "session.messenger" CFC which basically keeps an array of
different "messages" I want to show to the user.  Then, in my validation
scripts I can   do something like:

session.messenger.newError(errorMesage);

And then grab those messages to show to the user in my page wrapper
(session.messenger.getMessages())

Obviously, using session-cached CFCs won't work in a cluster (absent sticky
sessions).

In theory, the only locking issues you should have are race conditions --
but, it sounds like if you're just doing some queries that should not be an
issue.



> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Michael Dinowitz
> Sent: Friday, July 25, 2003 9:51 AM
> To: [EMAIL PROTECTED]
> Subject: [CFCDev] CFC Caching
>
>
> I'm playing around with a new methodology and part of it involves
> caching some
> CFCs into the application scope. I see no problem doing so but
> others may know
> more than I in this. Is there a savings in doing this? Any
> overhead or problems
> that I don't foresee?
>
> The first thing I do is check if its in the application scope and
> if not, create
> and initialize it. Then I just use it when needed. There's no
> locking going on
> as the CFC is only doing queries and related operations (no
> insert or update
> operations).
>
> Michael Dinowitz
> Finding technical solutions to the problems you didn't know you had yet

----------------------------------------------------------
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).

Reply via email to