- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
要利用 ColdFusion 2016's new setting searchImplicitScopes="false"
带来的性能提升,需要做什么? :
... bypasses searching for a variable in the implicit scopes thus finding the variables defined in the application faster.
我们是否应该在 ColdFusion 2016 中使用 searchImplicitScopes="false"
开始限定 Variables
和 This
范围?
我找不到任何关于 CF2016 中隐式作用域的文档。我很确定 local
和 arguments
作用域在函数内部没问题,但是像 variables
和 this
在 CFC 中?
最佳答案
范围所有的东西!!!
CFC 中的variables
作用域对于CFC 中的所有函数都是全局的。
CFC 中的 this
作用域对于 CFC 中的所有函数都是全局的,也可以从 CFC 的调用者中引用。
如果您没有在 CFC 中定义变量的范围,则它默认为 variables
范围。
<--- this_test.cfc --->
<cfcomponent>
<cfset variables.foo = "This is my CFC global variable." />
<cfset this.bar = "This variable is global to my CFC and can be referenced externally." />
<cfset narf = "Global variable! Point!" />
<cffunction name="getNarf" access="public">
<cfreturn narf />
</cffunction>
</cfcomponent>
测试调用:
<cfset test = new this_test() /><p></p>
<p><cfoutput>
<li>#test.foo#</li>
<li>#test.bar#</li>
<li>#test.narf#</li>
<li>#test.getNarf()#</li>
</cfoutput></p>
foo
在 variables
范围内,你会得到一个错误:Element FOO is undefined in TEST.
bar
位于 this
范围内,因此您可以获得 test.bar
的输出。
narf
在 variables
范围内,你会得到一个错误:Element NARF is undefined in TEST.
- 获取
narf
值的唯一方法是让函数返回它。
更新
searchImplicitScopes
可以关闭 CF 的范围搜索功能。因此,如果您不指定范围,它就不会查找范围的层次结构。问题是,默认情况下,未限定范围的变量最终会出现在 variables
范围内吗?我会说,是的,因为这是自 CFC 首次亮相以来的默认设置。
不管使用那个设置,我仍然说范围一切。他们创建隐式 local
范围的全部原因是因为:
- 开发人员不习惯
var
作用域函数局部变量
- 以前的开发人员倾向于使用
var local = structNew()
,因此他们只需 var
确定一个变量的范围。
- 2 还赋予了他们返回函数局部变量集合的能力。
- 从 CF 9 开始,当
var a = 0
与 local.a = 0
相同时,您可以删除 var local = structNew 的所有实例()
,只要您还“确定范围”并将这些私有(private)变量引用为 local.a
。
底线
如果 CF 必须在每个请求上查找变量范围,就会有一些性能开销。如果您使用 searchImplicitScopes=false
关闭该查找,您应该会获得一些性能提升。但是,这实际上应该取决于您的应用程序和平均请求负载。
关于coldfusion - 在 CF2016 中,变量和 This 是否被视为 CFC 内的隐式范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35804138/
我正在编写一个我想经常运行的计划任务。 问题是,如果服务器遇到高流量负载,我不希望运行此任务。 除了从 java 获取空闲/总/最大内存之外,还有什么方法可以尝试确定此任务是否应该继续? 最佳答案 G
我知道 coldfusion builder 已发布用于开发 coldfusion 9 应用程序。现在我的问题是 coldfusion builder 是否支持 COLDFUSION 8 开发?非常感
我正在尝试出于学习目的测试 Coldfusion,但我真的不知道非免费企业版添加到免费开发者版的附加功能是什么。 谢谢! 最佳答案 从法律上讲,Enterprise 是供公众消费的,而 Dev 不是。
我一直在玩这个问题一段时间了。我想要实现的是保存到MySQL数据库,然后输出到窗口,一般确认的表情符号如😀😁😂(是的,21世纪问题) 经过大量的修补和遵循本网站上的各种教程和答案之后,我设法实现
嗨伙计!我有一个关于coldfusion用户的简单问题,有没有人知道如何将动态数字转换为小数,例如我有一个代码:#number#,它等于,例如 10 但我需要将它写为 0.10 我该怎么做做吗? 试过
尝试使用方括号表示法来引用动态变量。 (我正在遍历由查询创建的一组产品,为每个与其唯一 SKU 相关联的字段创建字段,如果您对应用程序感到疑惑) 我已将其缩小到这段代码,当我尝试运行它时会抛出“无效表
我刚刚下载了 ColdFusion Builder (CFB),现在我正在尝试编写一个简单的“Hello World”应用程序。但我首先需要某种服务器,不是吗?现在我到底在这里寻找什么? “ColdF
我们正在运行 ColdFusion MX7。 我们遇到的一个问题是,我们在很多页面中都使用了很多功能。将它们放在“全局”ColdFusion 范围内会很好,而不是必须将它们包含在我们所有的页面中。 有
我已经尝试使用 key 工具将证书从 First Data 导入到我的 ColdFusion 9 设置中: keytool -importcert -keystore MYCF9Dir\runtime
在 ColdFusion 组件中,我声明了一个这样的函数: string function render(required Array actions) output=false { //... }
背景 : 我有一个处于设计阶段的新站点,正在考虑使用 ColdFusion。服务器目前正在使用 ColdFusion 和 Python 进行设置(为我完成)。 使用什么是我的选择,ColdFusion
我计划在服务器上从 ColdFusion MX7(Server 2003)迁移到 ColdFusion 11(Server 2012)。有一个其他服务器,我需要从 ColdFusion 8(服务器 2
一些背景知识:我正在从事一个将另一种脚本语言的网络应用程序转换为 ColdFusion 的项目。我遇到的一个问题是旧技术有一些函数名称与 CF 中的函数相同,但工作方式略有不同。不幸的是,在大多数情况
在 this page ,它谈到了 Windows NT、2000、XP 和 2003。幸运的是,我有一台 Windows 7 机器。 第一行说: In User Manager for Domain
ColdFusion 中获取季度第一天和最后一天的最快方法是什么? 似乎没有为此内置功能。 最佳答案 季度第一天: FirstDayOfQuarter = CreateDate(year, (quar
我正在尝试在新的 Windows 服务器 (Windows Server 2012 R2) 上安装 ColdFusion 11(标准版)。安装显然是成功的,但是当我进入管理员安装最新更新时,我不能。当
我有: 服务器详情 服务器产品 ColdFusion 版本 9,0,1,274733 版本标准 操作系统 Windows Server 2008 操作系统版本 6.0 Adobe 驱动程序版本 4.0
我们有一组文件需要 ColdFusion 复制到网络共享。但是,我们无法更改运行 ColdFusion 服务的用户,这意味着 ColdFusion 没有足够的权限访问任何网络共享。我们确实有可以访问的
这对我来说是新的:我正在查看 ColdFusion 网站。 问题是我什至找不到连接字符串。在一些 qryXXX.cfm 文件中,我发现 但我就是找不到这个数据源的存储位置。 最佳答案 数据源在 Co
停止ColdFusion输出的空白的正确方法是什么? 我知道有cfcontent和cfsetting enableCFoutputOnly。正确的方法是什么? 最佳答案 除了,和是。您可以使用它删
我是一名优秀的程序员,十分优秀!