Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

CFquery cachedwithin

Participant ,
Jan 04, 2012 Jan 04, 2012

I have custom page for all the query executions. to the custom page i am sending the db credentials and  cachedwithin parameter.

i am checking what will happen  if i set the timespan to 0,0,0,0 (which is default in the code). for all the queries the query name is same,so will that take same data results for all the queries. is there any option as no cache in cfquery.

ex: i am executing a query where it will take the control id for increment. i am executing this many no of times will this take the same results or will it fetches the data each time from the database when i given the cachewithin as 0,0,0,0.

TOPICS
Database access
2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 04, 2012 Jan 04, 2012

If you set the CACHEDWITHIN to a timespan of 0, it will not cache the query and will reexecute the query each time.

If your query's SQL statement differs each time it is executed, CFQUERY will reexecute the query each time also, although the results of the previous execution will have been cached. Cached results are only used if the datasource, connection string, and SQL are identical.

Dave Watts, CTO, Fig Leaf Software

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 04, 2012 Jan 04, 2012

as i said earlier, i am trying to read the table which is having the id in it, which will changes regularly. so if i set the cache value to 0 it will execute the query everytime at db?

is there any option to set not to cache the qeury.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 04, 2012 Jan 04, 2012

Per my previous response: if you set the CACHEDWITHIN to a timespan of 0, it will not cache the query and will reexecute the query each time.

There is an option to not cache the query - don't use CACHEDWITHIN or CACHEDAFTER.

Dave Watts, CTO, Fig Leaf Software

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 18, 2012 Jan 18, 2012
LATEST

vksrinu wrote:

I have custom page for all the query executions. to the custom page i am sending the db credentials and  cachedwithin parameter.

i am checking what will happen  if i set the timespan to 0,0,0,0 (which is default in the code). for all the queries the query name is same,so will that take same data results for all the queries. is there any option as no cache in cfquery.

ex: i am executing a query where it will take the control id for increment. i am executing this many no of times will this take the same results or will it fetches the data each time from the database when i given the cachewithin as 0,0,0,0.

I am assuming you are passing the value of the cachedWithin variable dynamically, and wish to know the value of cachedWithin for which the query wont be cached (all other variables remaining the same). The secret is to realize that createTimeSpan() returns a number of days. Thus, createTimespan(0,0,30,0) is equal to approximately 0.02083. That is, 30 minutes is approximately 0.02083 days.

Now, let us suppose the variable you are dynamically passing for cachedWithin is cachedPeriod.

<cfquery cachedWithin="#cachedPeriod#">

Then you can be sure the value cachedPeriod=1 will cache for 1 day, cachedPeriod=0.25 for 6 hours, and so on. If you set cachedPeriod to 0 or to a negative number, the query wont cache.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources