I definitely do want to use the cached object data.  I'm not adding
complexity and pain, I'm removing it.  Now I won't have to write facades.

Here's another attempt at explaining what I'm trying to do, and this time
I'll get more specific.

I have a database table of plants.  I created a plantSet and a plant cfc.
The plantSet cfc, when init() is run, will create a plant object for each
row, and save them in arrays or structures under 'instance'.

The plantSet object is stored in an objectCache cfc, and init() is only
called the first time, before it is put in the server scope.  The
objectCache cfc itself is stored in the server scope.

Now, when I get plantSet back out of the objectCache cfc and
plantSet.getPlant("Boston") is called, I don't have to requery the database,
I can just return the Boston plant from a structure in plantSet.

This doesn't work, though, when Flash creates the plantSet object, because
it doesn't get the server one.  So I have to write a facade for Flash that
first gets the cached plantSet object, then calls getPlant.

I believe I've followed the recommendations from you and Nathan so far.

It'd be simpler to have plantSet run init() on itself the first time it is
created, and store itself in the server scope.  Then every time plantSet is
recreated, it will just retrieve its cached version of itself.  I can
accomplish this by keeping data out of 'this' and just caching 'instance'
(actually I use keep and self, but let's say it's instance).

Now, when flash calls plantSet.getPlant('Boston'), plantSet uses the cached
version of plantSet's data to return the Boston plant object.  In effect,
plantSet IS the cached version of itself because I've replaced all its data
with what was cached.  The only difference is that if I've made any changes
to the plantSet methods, those actually do get used instead of using cached
methods (since I'm not caching the methods, just the data).  I believe that
to be a benefit.


-----Original Message-----
From: Sean A Corfield [mailto:[EMAIL PROTECTED]
Sent: Friday, August 15, 2003 3:04 PM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] CFC Persistance


On Friday, Aug 15, 2003, at 11:35 US/Pacific, Brad Howerter wrote:
> Actually, I don't need to do a deep copy.  I can just use 'instance' 
> instead
> of the 'this' scope and then set this.instance = server.foo.instance.

That just makes 'instance' refer to the data in the cached object. If 
you change data via that reference, you will be changing the cached 
object data which is probably not what you want.

You probably want:
        instance = duplicate(server.foo.instance);
or:
        instance = structCopy(server.foo.instance);

But, again, you're now copying a lot of data which may be as expensive 
as the initialization!

Then again, if you're *not* changing the instance data, why bother 
creating a new object instance in the first place?

You still haven't explained what you are really trying to do - from the 
amount of pain and complexity you're going through, I can almost 
guarantee that you're going about this the wrong way...

Sean A Corfield -- http://www.corfield.org/blog/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

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

Reply via email to