On Saturday, Mar 29, 2003, at 16:13 US/Pacific, Matthew Walker wrote:
> I am only dabbling in CFCs but it seems sensible to me to retrieve a
> structure of related information using one getter, then just accessing
> that.
> But maybe I just don't "get" CFCs. Perhaps it's up to the CFC to cache
> that
> info so that endless database requests aren't required. For example,
> the
> first getSomething() could query the database for more than just the
> one
> requested field, and store the whole lot in a cache. Any following
> getSomethingElse() could grab the data from that cache.
Yes, that's a pretty good way to implement it (so I'd say that you do,
indeed, "get" CFCs). In fact, you could have a method that gets all the
data, declared access="private", and then in each of your
'getSomething()' methods, you test whether the data is already in cache
and, if not, call the private 'getAllData()' method to load it:
<cfcomponent>
<cfset isCached = false>
<cffunction name="getAllData" access="private">
... load all the data into some instance variable ...
<cfset isCached = true>
</cffunction>
<cffunction name="getSomething">
<cfif not isCached>
<cfset getAllData(...)>
</cfif>
<cfreturn myCache.something>
</cffunction>
</cfcomponent>
Sean A Corfield -- http://www.corfield.org/blog/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4