Reputation: 2525
Here is my code
<cfquery name="employeeData" datasource="xyz" cachedwithin="#CreateTimeSpan(0,0,60,0)#">
SELECT employee, salary
FROM employee
</cfquery>
<cfquery name="wellPaidEmployee" dbtype="query">
SELECT employee, salary
FROM employeeData WHERE salary > <cfqueryparam cfsqltype="cf_sql_integer" value="10000">
</cfquery>
Condition:
The first query EmployeeData gets timed out due to some issue and throws an error "query timed out"
Question:
Upvotes: 1
Views: 601
Reputation: 11120
Too long for a comment.
Queries timing out, and caches expiring are two different things.
<cfquery name="employeeData" datasource="xyz" cachedwithin="#CreateTimeSpan(0,0,60,0)#">
SELECT employee, salary
FROM employee
</cfquery>
Will run when it is first hit. It will also save its data for 60 minutes. If that data is accessed again in 60 minutes, the cache timeout will reset back to zero. In theory, if this data is accessed every 60 minutes, it will never hit the database.
As for
<cfquery name="wellPaidEmployee" dbtype="query">
SELECT employee, salary
FROM employeeData WHERE salary > <cfqueryparam cfsqltype="cf_sql_integer" value="10000">
</cfquery>
It does not know, nor does it care if the underlying data came from a cache or not. It will just return the results.
If you are getting a "query timed out" error. That is a completely different problem. There is something wrong with how ColdFusion is connecting to the database OR there is a problem with the database itself.
Upvotes: 0
Reputation: 4694
Only successful db requests are cached so the EmployeeData query will run on next pass.
The wellPaidEmployee query will run if employeeData does not error.
Upvotes: 3