Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top