cfquery with cachedwithin woes. Also.. cfobjectcache filter issues

117 views
Skip to first unread message

aree

unread,
Jan 4, 2017, 11:05:45 AM1/4/17
to Lucee
I have an application I am moving from BD to lucee.  However I am stuck in a giant pitfall.  For speed issues I cache many queries so I don't have to go to the database often.  But I just can't find a suitable solution here.

Issue 1: The cachedwithin attribute on cfquery tags does not allow for uncaching when I use a #CreateTimeSpan(0, 0, 0, 0)#.  I am unable to find a easy way to uncache a specific query.

Issue 2: The filter attribute of <cfobjectcache> does not seem to apply to an action="clear".

The only workable solution I have found is to delete ALL cached queries by doing
<cfobjectcache action="clear" type="query">

However, this forces EVERY query to uncache which is totally unecessary.  I would hope/expect for this to work, but it does not
<cfobjectcache action="size" result="mystring" filter="myQueryForData">

Would appreciate input!  To test this just change the first line to a valid datasource.

---

<cfset yourdatasource = "pwm">

<style> div.ex { border:1px solid black; margin:10px; background-color:yellow; width:500px; } </style>
<cfset selectQuery = "select #RandRange(0,999)# as testColumn">

<cfquery datasource="#yourdatasource#" name="exampleQuery" cachedwithin="#CreateTimeSpan(0, 0, 10, 0)#">#selectQuery#</cfquery>
<div class="ex">Result 1:<cfdump var="#exampleQuery#"></div>
<!--- Result: not cached, it is run for the first time --->

<cfquery datasource="#yourdatasource#" name="exampleQuery" cachedwithin="#CreateTimeSpan(0, 0, 0, 0)#">#selectQuery#</cfquery>
<div class="ex">Result 2:<cfdump var="#exampleQuery#"></div>
<!--- Result: this is a cached query while it should not be --->

<cfquery datasource="#yourdatasource#" name="exampleQuery" cachedwithin="#CreateTimeSpan(0, 0, 0, 0)#">#selectQuery#</cfquery>
<div class="ex">Result 3:<cfdump var="#exampleQuery#"></div>
<!--- Result: this is still a cached query while it should not be --->

<cfquery datasource="#yourdatasource#" name="exampleQuery">#selectQuery#</cfquery>
<div class="ex">Result 4:<cfdump var="#exampleQuery#"></div>
<!--- Result: not a cached query, we did not ask for it to be --->

<cfquery datasource="#yourdatasource#" name="exampleQuery" cachedwithin="#CreateTimeSpan(0, 0, 10, 0)#">#selectQuery#</cfquery>
<div class="ex">Result 5:<cfdump var="#exampleQuery#"></div>
<!--- Result: We would hope for this to NOT BE CACHED.  But it is --->

<cfobjectcache action="clear" type="query" filter="exampleQuery">
<div class="ex">Result 6:<cfdump var="#exampleQuery#"></div>
<!--- In theory this would throw an error because we asked for it to be uncached.  But filter is not used with action=clear --->

<cfquery datasource="#yourdatasource#" name="exampleQuery" cachedwithin="#CreateTimeSpan(0, 0, 10, 0)#">#selectQuery#</cfquery>
<div class="ex">Result 7:<cfdump var="#exampleQuery#"></div>
<!--- Result: expect this query to not be cached because of the cfobjectcache command above, but the query is still cached --->

<cfobjectcache action="clear" type="query">
<div class="ex">Result 8:<br>Can't show, but the object is cleared.  Evidenced by the next query #9 below.</div>

<cfquery datasource="#yourdatasource#" name="exampleQuery" cachedwithin="#CreateTimeSpan(0, 0, 10, 0)#">#selectQuery#</cfquery>
<div class="ex">Result 9:<cfdump var="#exampleQuery#"></div>
<!--- Result: not cached, but no queries are cached, so we have to go back to the database for EVERYTHING again --->

Zac Spitzer

unread,
Jan 9, 2017, 7:18:29 PM1/9/17
to lu...@googlegroups.com
here is the relevant bug, i see you have already found it :)

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/9e6baf2c-4549-4a6d-a3ee-30dc001bbe38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Zac Spitzer
+61 405 847 168

Reply all
Reply to author
Forward
0 new messages