Changes to cached query behavior between CF 10 and CF 2016

I am updating from Adobe CF10 to CF2016 and noticed that in CF2016, modifications to the cached request object seem to be being cached. It doesn't look like CF10.

For example:

<cfquery datasource="myDs" name="rs" cachedwithin="#createtimespan(0,0,5,0)#">
    SELECT 10 AS value
</cfquery>

<cfset rs.value = 2016>

<cfquery datasource="myDs" name="rs" cachedwithin="#createtimespan(0,0,5,0)#">
    SELECT 10 AS value
</cfquery>

<!--- CF10 outputs 10 --->
<!--- CF2016 outputs 2016 --->
<cfoutput>#rs.value#</cfoutput>

      

I do not understand something? I couldn't find this documented. RTFMs are welcome.

+3


source to share


1 answer


Let's define the request object, name it variables.rs

and put it in the cache.



<cfquery datasource="myDs" name="rs" cachedwithin="#createtimespan(0,0,5,0)#">
    SELECT 10 AS value
</cfquery>
      

This query object contains one record and one column (named value

). If we output the value of that one column of the record that is referenced as variables.rs.value

, we see the value 10

.

Now let's define a struct

named variables.rs

with one key with name value

and value 2016

. If we output this referenced variables.rs.value

value, we will see the value 2016

.

Finally, run this query again.



<cfquery datasource="myDs" name="rs" cachedwithin="#createtimespan(0,0,5,0)#">
    SELECT 10 AS value
</cfquery>
      

But the query ran over time cachedwithin

and the recordset never changed, so there is no need to update the query cache. Therefore the variable variables.rs

will not be updated.

This leaves variables.rs

as a structure, with a named value

key whose value is 2016

.

This appears to be the correct progression of events to occur. It was probably a bug in previous versions that caused them to act the way they did, which was fixed in 2016 (yay !?).

It is likely that no one has created a bug report that outlined this exact issue with the steps to recreate, so the CF development team don't know this thing.

Interoperability may find it easier for you to refactor your code than to hold your breath waiting for the problem to be sequenced, accepted, fixed, and released. But you could at least do it. My company filed a number of significant functionality changes between 2016 and previous releases and has had most, if not all of them fixed.

+5


source







All Articles