caching - CachePut 跳过必填字段

标签 caching coldfusion optional-parameters coldfusion-2016 cfcache

我想使用CachePut()。我特别想要

 CachePut(id = _attr.path, value = attr.qryPath, region = variables.cacheRegion);

idvalueregion 分别是第 1 个、第 2 个和第 5 个参数。

Adobe 表示第三个到最后一个参数是可选的。来源:https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-c-d/CachePut.html

如何通过第一、第二、第五项?当我尝试时,我得到:

enter image description here

最佳答案

来自上述评论:

CF2016没有做命名参数。那是从 CF2018 开始的。所以你必须取出名字并传递第三和第四位置的东西。通常您只需传递正常的默认值即可。我不确定 CF2016 中这个标签的含义是什么,但 F2018 文档 http://cfdownload.adobe.com/pub/adobe/coldfusion/2018/publicBeta/NamedParametersColdFusion2018.pdf似乎表明默认值都是空字符串。

尝试

CachePut(_attr.path,attr.qryPath,"","",variables.cacheRegion) ;

示例:

https://cffiddle.org/app/file?filepath=a253f587-43fa-482f-b4cd-c7bbb8b45f3d/252b1e4b-d303-4a16-9d80-7c657e6e7770/7c0dc772-099c-4827-8e2f-068b2e32a4d8.cfm

<cfscript>
    attr.Path = "_path" ;
    attr.qryPath = "querypath" ;
    variables.cacheRegion = "newCacheRegion" ;

    CacheRegionNew(variables.cacheRegion);

    //WriteDump(CacheGetProperties(variables.cacheRegion));

    CachePut(attr.Path,attr.qryPath,"","",variables.cacheRegion);

    writeDump(CacheGet(attr.Path,variables.cacheRegion));
</cfscript>

关于caching - CachePut 跳过必填字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53876502/

相关文章:

c# - 根据其他参数设置可选参数默认值

asp.net - ASP.NET 缓存的位置

database - 在 Golang 中缓存数据库结果( revel )

html - 十六进制颜色代码倍数 #

sql - Coldfusion 循环查询并仅显示一次 html 标记

java - Java中重载方法时,在哪里计算额外的参数数据?

mysql - 如何优化每个用户的自定义搜索结果

java - GWT - 防止 PDF 文件在 IE 中缓存?

sql - 如何提取<CFQUERY>的WHERE子句中的子字符串?

.net - 为什么 ObjectDataSource 需要函数的可选参数?