我從CF8到9的變化一直都是盲目的,在這種情況下,如果不創建自定義緩存或其他一些不值得花費的艱鉅解決方法,寫入磁盤緩存將不再可能。是否可以解析ColdFusion 9.0.1緩存內存的內容?
在這個時候,我已經放棄了嘗試轉換應用程序以支持,如果可能的話,將緩存文件內容寫入靜態cfm文件的方法。我現在更加好奇,因爲我已經深入瞭解了它。我在找一個比我自己有更多經驗的人。
我想什麼,瞭解或知道如何與模板緩存做的是:
- 能夠針對違約或自定義緩存模板,它不清除整個緩存刷新。
- 出於好奇或調試方法查看或解析特定緩存模板的內容。
這是我正在使用的代碼,需要CF 9.0.1,由於一些緩存功能在9.0中不可用,這是因爲我相信EhCache 2.0的增加。
<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>
沒有錯誤應該存在,但它被編輯從原來在這裏發佈。