Solved

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

Posted on 2014-09-09
6
250 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
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 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