代码之家  ›  专栏  ›  技术社区  ›  James A Mohler Nika

正在跳过必填字段的CachePut

  •  3
  • James A Mohler Nika  · 技术社区  · 6 年前

    我想用 CachePut() . 我特别想

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

    id value ,及 region 分别是第一、第二和第五个参数。

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

    enter image description here

    1 回复  |  直到 6 年前
        1
  •  3
  •   Shawn    6 年前

    根据以上评论:

    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>
    
    推荐文章