Yes, that's exactly how you should go about doing caching.  However,
rather than using a UDF and an application variable, use a CFC method
and then stash that CFC in the application scope.  Much more flexible
and better encapsulated.

<cfcomponent>
  <cffunction name="getQuery">
    <cfset var q = "" />
    <cfif NOT structKeyExists(variables, "myQuery")>
      <cfquery name="q" ...>
      </cfquery>
      <cfset variables.myQuery = q />
    </cfif>
    <cfreturn variables.myQuery />
  </cffunction>
  <cffunction name="flushQuery">
    <cfset structDelete(variables, "myQuery", false) />
  </cffunction>
</cfcomponent>

cheers,
barneyb

On Wed, 23 Feb 2005 22:49:59 -0000, Adrian Lynch
<[EMAIL PROTECTED]> wrote:
> One tip that might help if you go down the route of caching it all and then
> the need arises to cut back on the cached data, abstract out the call to get
> data so caching or not caching has no effect on the output of data.
> 
> For example, don't use
> 
>         <cfquery name="APPLICATION.yourQuery">
> 
>         </cfquery>
> 
>         APPLCIATION.yourQuery.yourColumn
> 
> But instead maybe use this
> 
>         <cffunction name="getQuery">
> 
>                 <cfset var q>
> 
>                 <cfif cache conditions here>
>                         <cfquery name="APPLICATION.q">
> 
>                         </cfquery>
>                 </cfif>
> 
>                 <cfreturn APPLICATION.q>
> 
>         </cffunction>
> 
>         <cfset localQuery = getQuery()>
> 
>         #localQuery .yourColumn#
> 
> Does that make sense? Anyone care to comment? Logic might be wrong but I'm
> just trying to explain the concept.
> 
> Ade
> 

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 50 invites.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:196243
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to