强制coldfusion 8重新加载组件缓存?

时间:2012-12-14 09:03:17

标签: coldfusion coldfusion-8

ColdFusion 8正在缓存我的cfcs。发展处于停滞状态。我无法访问管理面板。我有什么选择?

3 个答案:

答案 0 :(得分:2)

1)访问CF管理员。

真。我不想在任何我无法控制的地方举办任何活动

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() />

答案 1 :(得分:0)

我使用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调用cfm页面?reinit = 1 3.观察反映cfc的变化。

希望它有所帮助...

答案 2 :(得分:0)

我知道这篇文章很旧,但是我需要针对(更现代的)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>

Adob​​e似乎已将CF管理员功能与运行时组件分开。那确实是唯一的区别。上面的版本还显示了如何清除组件缓存。

注意:我所做的事情与CFNinja的回答非常相似,但是一个站点(大约25个类似站点中的一个)只是不会清除应用程序范围的组件,而旧版本仍然以某种方式保留在缓存中。

相关问题