• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Coldfusion 11 - Clear database cache

New Here ,
Jan 07, 2015 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

Views

2.5K

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
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 08, 2015 Jan 08, 2015

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

Votes

Translate

Translate
Community Expert ,
Jan 08, 2015 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().

Votes

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
community guidelines
New Here ,
Jan 08, 2015 Jan 08, 2015

Copy link to clipboard

Copied

Thanks BKBK, that worked first time!

Many thanks for your help.

Kind regards

Stuart

Votes

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
community guidelines
Community Expert ,
Jan 08, 2015 Jan 08, 2015

Copy link to clipboard

Copied

Glad to hear. Best wishes.

Votes

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
community guidelines
Advocate ,
Jan 08, 2015 Jan 08, 2015

Copy link to clipboard

Copied

LATEST

You guys learned me something. I have never used nor knew about cacheRemoveAll. I guess that is my "something new" for today. Thanks.

Votes

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
community guidelines
Resources
Documentation