?
Solved

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

Posted on 2014-09-09
6
Medium Priority
?
295 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 668 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
TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 1332 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 1332 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

A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

Question has a verified solution.

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

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 …
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

800 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