Copy link to clipboard
Copied
Hi
We've just upgraded to CF11 update 3 on a 64bit Windows 2008 Server from CF10 and have found that my previous code to clear cached database queries no longer works as instantly or reliably as it did previously.
I'm currently using the following code in my application.cfc file.
This code would run if I were to hit the following page on the website... index.cfm?reinit=yes
<cffunction name="onRequestStart" hint="">
<cfif structKeyExists(URL, "reinit")>
<cfset cacheRemoveAll()> <!--- Added 7th Jan 2015 without improvement--->
<cfset onApplicationStart()>
<cfobjectcache action="clear">
</cfif>
</cffunction>
Here's an example of a query I'm trying to clear the cache of
<cfquery name="rs_Issue" datasource="#APPLICATION.dsource1#" cachedwithin="#CreateTimeSpan(0,1,0,0)#">
SELECT Issue_ID, Issue_Name
FROM Issue
WHERE Issue_Status = <cfqueryparam cfsqltype="cf_sql_varchar" value="Current">
</cfquery>
Has anyone got any suggestions of what I'm doing wrong to clear the database cache (either application or server wide)?
Thanks
Stuart
stuartw81 wrote:
<cffunction name="onRequestStart" hint="">
<cfif structKeyExists(URL, "reinit")>
<cfset cacheRemoveAll()> <!--- Added 7th Jan 2015 without improvement--->
</cfif>
</cffunction>
You may have to go from the general to the specific. By default, ColdFusion caches queries in a 'region' of the cache named 'query'. You should therefore use cacheRemoveAll('query') in place of cacheRemoveAll().
Copy link to clipboard
Copied
stuartw81 wrote:
<cffunction name="onRequestStart" hint="">
<cfif structKeyExists(URL, "reinit")>
<cfset cacheRemoveAll()> <!--- Added 7th Jan 2015 without improvement--->
</cfif>
</cffunction>
You may have to go from the general to the specific. By default, ColdFusion caches queries in a 'region' of the cache named 'query'. You should therefore use cacheRemoveAll('query') in place of cacheRemoveAll().
Copy link to clipboard
Copied
Thanks BKBK, that worked first time!
Many thanks for your help.
Kind regards
Stuart
Copy link to clipboard
Copied
Glad to hear. Best wishes.
Copy link to clipboard
Copied
You guys learned me something. I have never used nor knew about cacheRemoveAll. I guess that is my "something new" for today. Thanks.