Solved

How to use CFCACHE to cache my SQL query ?

Posted on 2001-08-21
2
189 Views
Last Modified: 2013-12-24
Can anybody tell me how to use CFCACHE to cache my SQL query ?

I have a home page which will do a CFQUERY on a news update table but I would like to cache it so that everytime someone load the home page, it will not always doing the CFQUERY but getting the data from the cache file, if there is. I can't find it explain very well in ColdFusion help file.

Is there any sample scripts out there ?
0
Comment
Question by:ck969
2 Comments
 
LVL 19

Accepted Solution

by:
cheekycj earned 50 total points
ID: 6409850
CFCACHE is meant for content not queries.  If you have a dynamic page but can be cached when it has the URL params or something similar that is when you should use CFCACHE.

For caching queries use this:
<CFQUERY DATASOURCE="yourdsn" NAME="MyCachedQuery" CACHEDWITHIN="#CreateTimeSpan(0, 1, 0, 0)#">
   SELECT *
     FROM SomeTable;
</CFQUERY>

This caches the query for an hour.  You can change it as you need it.. the parameters are dd, hh, mm, ss for CreateTimeSpan.

CJ
0
 

Expert Comment

by:SpideyMod
ID: 8096549
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question