I’d like to make a proposal, and I wonder what others think. Let me expand on the title here.
If you’ve used CF’s query caching features, you almost surely know that when you run a query (or stored proc call) that uses cachedwithin or cachedafter, there will be a “cached” indicator in the resulting query metadata (if you dump it), or the debug output (if you’ve enabled it), or the RESULT struct (if you named one for the query).
And that’s always indicated (true or false) whether the result of the query result came from the query cache or not.
But the phrase “cached” is actually misleading, as it can be interpreted (especially by a newcomer to query caching) to indicate “whether the query WAS cached” (its results saved TO the query cache). That’s NOT its current purpose, of course.
To prevent confusion, I would propose that new indicators be created (in those 3 places) :
- “fromCache”: a boolean indicating whether the query results CAME from the query cache
- “wasCached”: a boolean to indicate whether the query results WERE saved to the query cache
I share more about this in a feature request I just filed in the Adobe Tracker site. I could have left it at that, hoping “someone might see it” but I thought perhaps some in the community may want to hear about this idea directly and perhaps offer feedback (whether here or in the ticket).
In the ticket I offer some sample code, and I acknowledge some other concerns (from the names I propose, to compat issues, and more). I also address those who may think “there’s really no reason to bother tracking also WHETHER the query result was cached” (there are more than one).
As I conclude there, I realize this “cached” indicator has worked like this for over 20 years. We who’ve used CF query caching for years have just accepted that “it is what it is” (an indicator of whether the result CAME from cache) …and perhaps never really cared to know if/when a query result WAS cached. But they are different things, and really they both have their value.
As the saying goes, I wanted to “run it up the flag pole” here.
[And yes, if the idea has merit, perhaps someone could get it added to Lucee before Adobe may. To be clear, Lucee currently returns the same simple “cached” indicator, as yes or no.]