Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to use CFCACHE to cache my SQL query ?

Posted on 2001-08-21
2
Medium Priority
?
196 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 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
What You Need to Know when Searching for a Webhost Provider
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

824 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