Solved

CFQuery with cachedWithin="#CreateTimeSpan(0,1,0,0)#"

Posted on 2014-09-09
6
231 Views
Last Modified: 2014-09-09
Hi,
  I have the following code in CFM page.

<CFQUERY NAME="GetCustomers" datasource="DSN" cachedWithin="#CreateTimeSpan(0,1,0,0)#">
      SELECT      *
         FROM         Customers
      ORDER BY CustomerName
</CFQUERY>

 What does cachedWithin="#CreateTimeSpan(0,1,0,0)# mean?
 The reason for asking is:

 I just added a new customer to  the CUSTOMER table in ACCESS. But that new customer does not show up in online  Order Form when the user selects the customer from the customer drop-down menu.
 And I suspect that it has something to do with cashedwithin statement.
 How can I make it so that when I add a new customer or new part into the tables, they would show up in drop down menu on the webpage?

Thanks.
0
Comment
Question by:sglee
  • 3
  • 2
6 Comments
 
LVL 19

Accepted Solution

by:
erikTsomik earned 167 total points
Comment Utility
to the best of my knowledge that will cache the query for duration of 1 hour and only then you start seeing the newly added record
0
 

Author Comment

by:sglee
Comment Utility
That is what I suspected. If I replace 1 with 0, what happens then?
cachedWithin="#CreateTimeSpan(0,0,0,0)#"
0
 

Author Comment

by:sglee
Comment Utility
What if I don't want any data cached?
What if I just want the query to be executed whenever online order form is displayed?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 333 total points
Comment Utility
EDIT
It clears that query from cache. So the query results will now include any new records.  Afterward, you can reset it back to cachedWithin="#CreateTimeSpan(0,1,0,0)#.  The query results will then be cached again, for the next 1 hour.
0
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 333 total points
Comment Utility
>> What if I don't want any data cached?

Run the query with cachedWithin="#CreateTimeSpan(0,0,0,0)#"  to ensure it's cleared from cache. May not be necessary, but won't hurt anything.  Then remove the cachedWithin attribute from the cfquery altogether.

>>  SELECT      *


Edit:  As an aside, try and avoid using SELECT *.  Among other reasons, I've read that CF sometimes caches the table structure when SELECT * is used.  (That's different than caching the data rows).  So if you add a column to the "customer" table, CF might not detect it. Not until you clear the template cache or restart.
0
 

Author Comment

by:sglee
Comment Utility
Thanks for the information.
I will simply remove cachedWithin="#CreateTimeSpan(0,1,0,0)#  from CFQuery all together from now on.
As to the SELECT *, thanks for the additional information and I appreciate it.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

10 Experts available now in Live!

Get 1:1 Help Now