Assuming application.persistentStuff is already instantiated as a singleton
and populated with the application-wide instance data you need, maybe
something like this would help:

on every request

<cfset perRequestCFC =
createObject('component','perRequestCFC').init(application.persistentStuff,u
rl,form)>
<cfset perRequestCFC.goForIt()>

? n.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of enigment
Sent: Friday, May 13, 2005 6:07 AM
To: [email protected]
Subject: [CFCDev] Confusion about persistent CFCs


There's a cfc that's used by every request, so for efficiency, I wondered
about creating it once, in the application scope, at app startup. However,
it does have instance data, so each request needs its own copy, and I'm
confused about how to manage that, or if that's even possible.

Schematic version, broken I think:
--------------
<cfset request.MyCFC = application.classes.MyCFC>
<cfset request.MyCFC.setArguments(url="#url#", form="#form#")>
<cfset request.MyCFC.go()>
--------------

Am I right that request.MyCFC refers to the same actual object instance as
application.classes.MyCFC? Not a copy, the exact same instance? If so, every
request from every user competes for that one instance and its instance
vars: chaos.

Instead, we need a way to create a full clone of application.classes.MyCFC,
a copy with no link to the original, so its instance vars can be
independent.

Is there any way to create that kind of deep copy of a persistent cfc? The
cf Duplicate function doesn't appear to be usable on cfc objects. Or can
app-level persistent cfcs only have instance data that's basically static?

One alternative is to make a brand new MyCFC instance every time, with
CreateObject. That was the original plan, workable, but it'd have to be
slower than copying one instance, if there's a way to make that work.

Another possibility is for MyCFC not to have any instance vars at all. It
could store the info that's now instance data in the request scope instead.
I'd prefer it kept its own data inside itself though.

How would you manage this?

Thank you,
e



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

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 words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm

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


Reply via email to