Solved

How to use CFCACHE to cache my SQL query ?

Posted on 2001-08-21
2
185 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now