Ok, that makes sense...

So, to be able to run a "master query" that would
essentially be an in-memory stand-in for the data
on the database, and be able to run *various* types
of queries on that data, rather than the exact same
query, I would need to put the "master query" into
a persistent scope.  Right?

Or, perhaps, to be able to run *various* queries on the
"master query", I would need utilized a query-of-query
setup with "master query" stored in memory?

I guess at this point, I'm uncertain of the difference
between utilizing a "cachedWithin" query as opposed to
a "query-of-query"...

Rick

-----Original Message-----
From: Dave Watts [mailto:dwa...@figleaf.com] 
Sent: Thursday, January 06, 2011 12:40 PM
To: cf-talk
Subject: Re: Accessing a cached query in one function from another...


> I haven't made use of a persistent scope to this point.
> I thought, perhaps, that just using:
>
> <cfquery name ="queryName" datasource="dsn" cachedWithin =
> "#createTimeSpan(0,1,0,0)#">
>
> in the opening tag made the query data persistent without
> utilizing a persistent scope.  As I mentioned to Justin, just
> my ignorance about how caching works.

It does make the query data persistent. However, it doesn't create a
persistent variable that you can directly access. This will simply
pull data from CF's memory rather than the database the next time you
run the same query (with the same SQL and tag attributes) within the
next hour. In this case, you'd simply rerun the function that calls
the query as if you hadn't run it before. The advantage of this sort
of caching is that you don't have to put anything in your code to take
advantage of it (other than the CACHEDWITHIN attribute).

If you want to get a variable that you can reference directly without
rerunning the CFQUERY, you need to store the query in a variable that
will be available from wherever you want to reference it. In this
case, you'd get rid of the CACHEDWITHIN attribute and just store the
query itself in the appropriate scope.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340521
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to