Solved

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

Posted on 2014-09-09
6
242 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
URL ReWrite configuration redirect all .htm to .cfm 8 159
How to create a bcc list for email using a query 3 35
C# script to Coldfusion 25 59
Cold Fusion Session Timing Out 11 60
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
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…

910 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

23 Experts available now in Live!

Get 1:1 Help Now