I've been blind sided by the change from CF8 to 9 where write to disk caching is no longer possible without creating a custom cache or some other drastic workarounds that are not worth the effort.
At this time I've abandoned trying to convert the application to uphold, if possible, the same method of writing the contents of a cache file into a static cfm file. I'm more curious now that I've dug into it a bit deeper. I'm looking for someone that has more experience with this than myself.
What I'd like to understand or know how to do with template cache is:
- Be able to target a template in default or custom cache and flush it without clearing the entire cache.
- View or parse the contents of a particular cached template either out of curiosity or debug approach.
This was the code I was tooling with, requires CF 9.0.1 due to some cache memory functions that are not available in 9.0 due to the addition of EhCache 2.0 I believe.
<cftry>
<cfcache action='serverCache' timeout='#CreateTimeSpan(0,0,0,10)#' stripwhitespace='true'
usequerystring='true'>
Stuff to cache.
<br/>
<cfoutput>#now()#</cfoutput>
<br/>
</cfcache>
<!--- Get the cached contents --->
<cfdump var="#cacheGetProperties()#">
<cfdump var="#getAllTemplateCacheIds()#">
<!---Locate a single cached item --->
<cfscript>
cacheArray = getAllTemplateCacheIds();
WriteOutput("Before<br/>");
for(i=1;i LTE ArrayLen(cacheArray);i=i+1)
{
writeOutput(cacheArray[i] & "<br/>");
if(FindNoCase(scriptPath, cacheArray[i]))
{
//expect only to find min and max one per string so no need to worry about out of bounds
cacheIDSubStr = REFind("[a-fA-F\d]{32}(?=_LINE:\d*$)",cacheArray[i],1,1);
cacheID = Mid(cacheArray[i],CacheIDSubStr.pos[1],CacheIDSubStr.len[1]);
//Failure to delete cache expected fireworks
//WriteOutput(cacheID&"<br/>");
//cacheObject = CacheGet(cacheID);
//CacheRemove(cacheID);
templateCache = cacheGetSession("template");
//Tooling around with the exposed guts of cacheGetSession
WriteDump(templateCache.getKeys());
}
}
</cfscript>
<cfcatch type="Any">
<cfscript>
writeoutput("Error:" & cfcatch.message);
</cfscript>
</cfcatch>
</cftry>
No errors should exist, but it was edited from the original to post here.