CFMX 6.1 Cached Query Problem:
I have an XML file that I'm reading into a query object (to facilitate faster search) using the QueryNew(), QueryAddRow() and QuerySetCell() functions. Now, I need to hit this query often and I decided that caching it would be a good idea. Hence I did a query of query on it like so
<cfquery name="somename" cachedafter="#Now()#" dbtype="query">
Select * from
myQuery
</cfquery>
where myQuery is generated from the XML file using the functions above. As can be seen, this was a self-defeating exercise, because even before control flowed to the cfquery tag, generating the "myQuery" query from the XML file would've already taken place. To get around the same, the first time I read the XML file into the query, I set a server variable with the LastDTModified of the XML file, and would compare the server variable and the current LastDTModified to effectively create 2 code blocks

<cfif ServerVariable GT CurrentLastDateModified>
Use cached query
<cfelse>
Create cached query
</cfif>
Now the problem is, to use the cached query, I have to the same sql statement and tag signature. I tried this in the "Use Cached Query" block-

<cfquery name="somename" cachedwithin="#CreateTimeSpan(365, 0,0,0)#" dbtype="query">
select * from myQuery
</query>

This actually worked! But without notice, every so often, it simply says "Query of queries error: No table myQuery found in Memory". I tried using cachedafter on both queries with the xml document's lastdtmodified to keep the queries same, but to no avail. The only way I've been able to make it run properly once it throws that error, was try flushing the cache more than once.
Any suggestions, ideas why this works but fails every so often.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to