Thanks, Nathan. I'm not sure what you mean by 'factory', but I think I'm doing those things today and they're not working out too well for stateless web service calls. I have to keep writing facade CFCs for stateless method calls. I was thinking my idea would enable me to avoid that. Even though it feels wrong to you, do you think it's possible? I can't get it to work; 'this' doesn't refer to the entire object.
-----Original Message----- From: Nathan Dintenfass [mailto:[EMAIL PROTECTED] Sent: Thursday, August 14, 2003 5:39 PM To: [EMAIL PROTECTED] Subject: RE: [CFCDev] Caching a CFC Well, not sure if it's necessarily such a "bad thing" the way you're talking about, but it does feel wrong (which is, I think why Sean can't even imagine you doing it ;). Two other suggestions: 1) Just do the caching outside of the component. Then, just use server.foo in your code to use the component. This gets you the benefits of not instantiating/initializing without making the component need to worry about the environment its operating in. 2) Build a factory-like component that you use to deliver new instances -- then in the factory component you can call newFoo(), which can either return the cached version or make a new one. Then the only component that has to worry about issue like caching of instances is specifically designed to do that rather than mixing that issue in with the other functionality of the actual component(s). You can then still cache the factory component instance itself. > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Behalf Of Brad Howerter > Sent: Thursday, August 14, 2003 3:19 PM > To: '[EMAIL PROTECTED]' > Subject: RE: [CFCDev] Caching a CFC > > > I'd instantiate it anyway, yes, but I wouldn't have to reinitialize it. > Pretend that part of the '...' below is a method to initialize the object > and it takes a long time to run. > > And that's why I want it to replace itself with an old instance of itself, > too, so it doesn't have to be reinitialized. > > -----Original Message----- > From: Nathan Dintenfass [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 14, 2003 3:25 PM > To: [EMAIL PROTECTED] > Subject: RE: [CFCDev] Caching a CFC > > > If you're going to end up instantiating this component anyway (which based > on that construct, it seems you'd do) why not do the caching outside the > component? > > Also, can you explain why the this = server.foo would be necessary in that > case? Once you are in the component, why are you wanting to > replace itself > with an old instance of itself? > > > > > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > Behalf Of Brad Howerter > > Sent: Thursday, August 14, 2003 12:37 PM > > To: '[EMAIL PROTECTED]' > > Subject: [CFCDev] Caching a CFC > > > > > > I'd like to have a CFC put itself in cache, and then replace itself with > > that cached object whenever it is created. > > > > Is that possible? Is it stupid? > > > > Will this code do the trick, or is 'this' not really a reference to the > > current object, but just a scope within the object? > > > > <cfcomponent displayname="foo"> > > <cfparam name="server.foo" default="#this#"> <!--- put this object > > in server cache ---> > > <cfset this = server.foo> <!--- replace this object with the cached > > one ---> > > > > <!--- methods to follow ---> > > ... > > </cfcomponent> ---------------------------------------------------------- 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). ---------------------------------------------------------- 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).
