cachedwithin with an timespan of zero no longer clears cache

Description

On Lucee 4.5, <cfquery cachedwithin="#createTimeSpan(0,0,0,0)#"> would run the query without caching, effectively clearing the cache for that query. In Lucee 5, cached results are returned. This breaks my standard cache-busting strategy in my legacy code.

Workaround: don't use cachedwithin.

Environment

Ubuntu 12.04, 16.04

Attachments

1
  • 03 Aug 2016, 09:40 pm

Activity

Show:

Patrick Quinn 16 November 2017 at 23:42

Thanks for the update, , and for all that testing effort as well. Very helpful to Lucee to have that kind of thorough testing help from our users. Glad to hear it's working for you.

Leon Miller-Out 15 November 2017 at 18:46

I'm happy to report that I've done some more testing, and I think my previous assessment was incorrect and that the fix is addressing my issue. Sorry for the drama!

Test code:

<cfset qry = QueryNew('blerg')> <cfquery name="populateCache" dbtype="query" cachedwithin="#createTimeSpan(0,0,0,1)#"> select * from qry </cfquery> <cfset QueryAddRow(qry)> <cfquery name="readCache" dbtype="query" cachedwithin="#createTimeSpan(0,0,0,1)#"> select * from qry </cfquery> <cfset QueryAddRow(qry)> <cfquery name="invalidateCache" dbtype="query" cachedwithin="0"> select * from qry </cfquery> <cfset QueryAddRow(qry)> <cfquery name="readNewCache" dbtype="query" cachedwithin="#createTimeSpan(0,0,0,1)#"> select * from qry </cfquery> <cfscript> WriteOutput("Was populateCache cached? #populateCache.isCached()#<br>"); WriteOutput("Was readCache cached? #readCache.isCached()#<br>"); WriteOutput("Was invalidateCache cached? #invalidateCache.isCached()#<br>"); WriteOutput("Was readNewCache cached? #readNewCache.isCached()#<br>"); WriteOutput("populateCache should find 0 rows. It found #populateCache.recordcount#<br>"); WriteOutput("readCache should find 0 rows. It found #readCache.recordcount#<br>"); WriteOutput("invalidateCache should find 2 rows. It found #invalidateCache.recordcount#<br>"); WriteOutput("readNewCache should find 2 rows. It found #readNewCache.recordcount#<br>"); </cfscript>

Output:

Was populateCache cached? false
Was readCache cached? true
Was invalidateCache cached? false
Was readNewCache cached? true
populateCache should find 0 rows. It found 0
readCache should find 0 rows. It found 0
invalidateCache should find 2 rows. It found 2
readNewCache should find 2 rows. It found 2

Leon Miller-Out 15 November 2017 at 17:24

For anyone who is still interested in seeing a complete fix for this issue, please check out issue 1586, which I have filed to address the remaining problem with cachedwithin.

aaron lim 21 October 2017 at 04:25

similar issue on <cfcache> tag:

<cfcache timespan="#createtimespan(0,0,0,0)#"> does not clear the cfcache copy

Leon Miller-Out 11 October 2017 at 15:35

I'm sorry to say this, but this bug is only partially fixed. The fixed part is that a query with cachedWithin=0 now skips the cache. The part that is still broken is that cachedWithin=0 does not clear the cached results for that query. So, cache invalidation of a particular query is still impossible.

I believe that the tests I wrote for this problem are not being executed as part of the test suite (due to the function having been renamed test2). https://github.com/lucee/Lucee/blob/master/test/tickets/LDEV0907.cfc#L41-L54

or , can we mark this bug as something other than DEPLOYED, or do we need to create a new issue?

Fixed

Details

Assignee

Reporter

Priority

Fix versions

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Affects versions

Created 30 June 2016 at 20:18
Updated 17 March 2021 at 07:01
Resolved 22 June 2017 at 04:21

Flag notifications