ColdFusion 8正在缓存我的cfcs。发展停滞不前。我没有访问管理面板的权限。我有什么选择?
发布于 2012-12-15 01:18:19
1)获取CF Administrator的访问权限。
真的。我不想在任何我无法控制的地方主持。
2)以编程方式清除缓存。
使用Admin API:
createObject("component","cfide.adminapi.runtime").clearTrustedCache()当然,如果您不能访问CFAdmin,那么您也可能无法访问它,但是值得一试。
根据this blog entry from Ray Camden的说法,在运行上面的命令之前,你需要通过API登录到管理员,这当然意味着在没有访问权限的情况下它不会工作。
<cfset API = createObject("component","cfide.adminapi.runtime") />
<cfset API.login(adminPassword="password") />
<cfset API.clearTrustedCache() />发布于 2012-12-18 23:25:32
我使用application.cfc清除所有的cfc缓存。
<!--- *****************************************************************
Run before the request is processed
************************************************************--->
<cffunction name="onRequestStart" returnType="boolean" output="false">
<cfargument name="thePage" type="string" required="true">
<cfscript>
if (structKeyExists(url,'reinit')) {
structClear(application);
structClear(session);
onApplicationStart();
onSessionStart();
}
</cfscript>
<cfreturn true>
</cffunction>这个想法是传递一个名为"reinit“的url变量。只要在URL中定义了此变量,就会启动应用程序。
为了测试这一点: 1.对cfc进行更改2.通过xxx.cfm?reinit=1调用cfm页面3.观察cfc中的更改是否已反映出来。
希望这能帮上忙。
发布于 2020-02-13 08:05:58
我知道这篇文章很旧,但我需要为(更)现代版本的ColdFusion ( 2016 )这样做,而Peter的答案在CF 2016上不起作用。我不想成为答案,只是为CF的更新版本做个注脚。
这是一个适用于CF 2016的版本:
<cfscript>
variables['adminPW'] = "my cf admin password";
cfAdminAPIAdmin = createObject("component", "cfide.adminapi.administrator");
cfAdminAPIAdmin.login(variables.adminPW);
cfAdminAPIRuntime = createObject("component", "cfide.adminapi.runtime");
// clear the component and trusted (template) caches
cfAdminAPIRuntime.clearComponentCache();
cfAdminAPIRuntime.clearTrustedCache();
</cfscript>Adobe似乎已将CF管理功能与运行时组件分离。这真的是唯一的区别。上面的版本也展示了如何清除组件缓存。
注意:我一直在做一些与CFNinja的答案非常相似的事情,但有一个站点(大约25个类似站点中的一个)就是不能清除应用程序范围的组件,旧版本以某种方式留在了缓存中。
https://stackoverflow.com/questions/13875479
复制相似问题