Highlighted

Coldfusion 11 - Clear database cache

New Here ,
Jan 07, 2015

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

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

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().

Views

2.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Coldfusion 11 - Clear database cache

New Here ,
Jan 07, 2015

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

Adobe Community Professional
Correct answer by BKBK | Adobe Community Professional

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().

Views

2.0K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 07, 2015 0
Adobe Community Professional ,
Jan 08, 2015

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().

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2015 0
New Here ,
Jan 08, 2015

Copy link to clipboard

Copied

Thanks BKBK, that worked first time!

Many thanks for your help.

Kind regards

Stuart

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2015 0
Adobe Community Professional ,
Jan 08, 2015

Copy link to clipboard

Copied

Glad to hear. Best wishes.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2015 0
Advocate ,
Jan 08, 2015

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 08, 2015 0