Solved

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

Posted on 2014-09-09
6
287 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 19

Accepted Solution

by:
erikTsomik earned 167 total points
ID: 40312417
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
ID: 40312433
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
ID: 40312496
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
Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 333 total points
ID: 40312501
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
ID: 40312552
>> 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
ID: 40312575
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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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