ColdFusion updated, and some notes about query caching

Earlier today the ColdFusion team released a big update for ColdFusion 11 and 10. You can read the juicy details here: ColdFusion 11 Update 3 and ColdFusion 10 Update 15 are available now. While looking over the release notes for ColdFusion 11, I saw this odd little gem:

Below caching functions now accept object instead of String parameter for CacheId attribute: 1) cacheGet
2) cacheRemove
3) cacheGetMetadata
4) cacheIdExists

That seemed…. weird. So I went over to the ColdFusion docs for cacheGet and was disappointed to find that no one had updated this. When you make a change to the language, you need to update the docs as well. Release notes in an update are not enough. I’ll raise this internally so hopefully it won’t happen again. There is also the corresponding need of an update for ColdFusion Builder. I’d have to assume (and I can definitely be wrong!) that this language tweak would require a minor update to CFB, so that should have been released as well. Again, I’ll raise this internally.

So what is this change about? I looked at the “Issues Fixed” document (PDF link) and discovered bug 3741588. Oh, if you click that link and end up back the bug tracker home page… yeah that’s a bug. Click it again. (sigh)

From what I can read in the bug report by itisdesign, at some point there was a change for queries that were cached using cachedWithin/cachedAfter. If you do not specify a specific cache ID for the query, then a Java object is used for the ID instead. Here is an example.


q = queryNew("id", "cf_sql_varchar", [{id:"a"}, {id:"b"}]);
q2 = queryExecute("select * from q", {}, {dbtype:"query",cachedwithin:createTimeSpan(0,0,1,0)});

q3 = queryExecute("select * from q", {}, {dbtype:"query",cachedwithin:createTimeSpan(0,0,1,0),cacheId:"mystuff"});

ids = cacheGetAllIds("QUERY");
writeDump(ids);

In the code above, I’m caching two queries, but I only specify a specific ID in the second one. Notice the result when I dump the IDs:

localhost_8501_test_cfm

Yep, a complex object. So the change is to allow this object to be passed as an ID value to various caching functions. Makes sense I suppose but wasn’t obvious to me. While investigating this I came across this document (Enhanced query caching using Ehcache) that talks about how queries may now be stored in fancy Ehcache versus ugly old school cache. This happened back in ColdFusion 10 and I knew it, but while reading it I discovered two new Application.cfc variables I had not heard of: cache.useInternalQueryCache and cache.querysize. These are not listed on the wiki so I fixed that: Application variables

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate for Extend by Auth0. He focuses on serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA https://www.raymondcamden.com

Comments