Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why won't this query cache in ColdFusion 9.01 using cfscript?

I am writing a query in ColdFusion 9.01 script and having trouble understanding why it is not caching the results. The same exact query will cache when executed using the CFML tag syntax.

The SQL, datasource, username, password are not changing. I have dumpped the cfscript query object after instantiating it and verified the cachedWithin argument was properly received during init. I'm stumped.

CFScript Version that will not cache

var Q = new Query(
     SQL="SELECT * FROM TABLE"
    ,cachedwithin=createTimeSpan(0,0,60,0)
).execute().getResult();

CFML Tag Version that will cache

<cfquery name="local.q">SELECT * FROM TABLE</cfquery>

Thank you for your time and help.

Aaron

like image 714
Aaron Greenlee Avatar asked Oct 26 '11 01:10

Aaron Greenlee


2 Answers

Give it a name! :)

var Q = new Query(
     SQL="SELECT * FROM TABLE"
    ,cachedwithin=createTimeSpan(0,0,60,0)
    ,name="myQuery"
).execute().getResult();

http://www.compoundtheory.com/?action=displayPost&ID=500

like image 71
Henry Avatar answered Oct 16 '22 09:10

Henry


here: http://adiefatlady.posterous.com/compound-theory-getting-cfscript-queries-to-c

like image 22
Frank Tudor Avatar answered Oct 16 '22 09:10

Frank Tudor