I found a piece of code that works under the ColdFusion 10 engine, but not under the ColdFusion 2016 (CF12) engine.
I have a CFC that houses cached queries that are grabbed by function calls. Say I have a query I want to cache, but I make a change to the db table that this query uses. I do not see the data in the returned cached query, so I need to refresh the query cache, simple enough. This is how I have my code set up:
<cffunction name="getVariables" access="public" returntype="query">
<cfargument name="time_span" required="true" default="#this.cacheSpan#" />
<cfset var qryGetVariables="">
<!--- IF REFRESH, NEW QRYTIMESPAN --->
<cfif arguments.time_span eq 0 AND NOT this.bln_refresh>
<!--- IF time_span 0 but not refresh, reset to original cache span --->
<cfset arguments.time_span = this.cacheSpan />
</cfif>
<cfquery name="qryGetVariables" datasource="#this.dsn#" cachedwithin="#arguments.time_span#">
select *
from get_variables
order by id, value
</cfquery>
<cfreturn qryGetVariables>
</cffunction>
I call a function in the same CFC that refreshes this query in the following manner:
this.bln_refresh = true;
<cfinvoke method="getVariables" returnvariable="qryReturn">
<cfinvokeargument name="time_span" value="0" />
</cfinvoke>
this.bln_refresh = false;
Again, this worked before on ColdFusion 10 but now it does not work on ColdFusion 2016. What do I need to do differently to refresh the cache of this specific query?
Much thanks to @Alex, I came across the following solution that appears to be working on our servers:
<cffunction name="getVariables" access="public" returntype="query">
<cfargument name="time_span" required="true" default="#this.cacheSpan#" />
<cfset var qryGetVariables="" />
<cfset var flt_qryTimeSpan=0>
<cfif NOT cacheIdExists("qryGetVariablesCache") OR this.bln_refresh>
<cfquery name="qryGetVariables" datasource="#this.dsn#" cachedwithin="#flt_qryTimeSpan#">
select *
from get_variables
order by id, value
</cfquery>
<cfset cacheRemove("qryGetVariablesCache") />
<cfset cachePut("qryGetVariablesCache",qryGetVariables,this.cacheSpan) />
<cfelse>
<cfset qryGetVariables = cacheGet("qryGetVariablesCache") />
</cfif>
<cfreturn qryGetVariables>
</cffunction>