【问题标题】:CachePut skipping required fieldsCachePut 跳过必填字段
【发布时间】:2018-12-21 07:16:10
【问题描述】:

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

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

id、value、region分别是第1、2、5个参数。

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

我如何通过 1、2 和 5?当我尝试它时,我得到:

【问题讨论】:

  • CF2016 没有做命名参数。那是从 CF2018 开始的。因此,您必须取出名称并在第 3 和第 4 位置传递一些东西。也许CachePut(_attr.path,attr.qryPath,"","",variables.cacheRegion)。我认为空字符串是第三个和第四个参数的默认值。
  • cfdownload.adobe.com/pub/adobe/coldfusion/2018/publicBeta/… 将空字符串显示为这些参数的默认值,但这适用于 CF2018。不知道CF2016是不是也一样。
  • cffiddle.org/app/… 确实让我使用空字符串。
  • @Shawn:空字符串方法似乎有效

标签: caching coldfusion optional-parameters coldfusion-2016 cfcache


【解决方案1】:

来自以上评论:

CF2016 没有做命名参数。那是从 CF2018 开始的。因此,您必须取出名称并在第 3 和第 4 位置传递一些东西。通常你可以只传递正常的默认值。我不确定 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-28
    • 1970-01-01
    • 1970-01-01
    • 2015-06-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多