Solved

How to use CFCACHE to cache my SQL query ?

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

17 Experts available now in Live!

Get 1:1 Help Now