3

I want to use CachePut(). In particular, I want to

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

id, value, and region are the 1st, 2nd, and 5th parameters respectively.

Adobe says the 3rd through last parameters are optional. Source: https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-c-d/CachePut.html

How do I pass in the 1st, 2nd, and 5th? When I try it, I get:

enter image description here

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
  • CF2016 didn't do named parameters. That started with CF2018. So you'd have to take out the names and pass something in the 3rd and 4th position. Maybe `CachePut(_attr.path,attr.qryPath,"","",variables.cacheRegion)`. I think empty string is the default value for the 3rd and 4th params. – Shawn Dec 20 '18 at 22:40
  • http://cfdownload.adobe.com/pub/adobe/coldfusion/2018/publicBeta/NamedParametersColdFusion2018.pdf Shows empty string as default for those arguments, but that applies to CF2018. Not sure if it's the same in CF2016. – Shawn Dec 20 '18 at 22:45
  • 1
    https://cffiddle.org/app/file?filepath=1936c021-a2d6-4ef2-8d96-05e4b3365d03/98051129-b58f-4125-b520-1c954e61a0a2/e6265da0-ede1-471a-96a4-47d7a7dec756.cfm does let me use empty strings. – Shawn Dec 20 '18 at 22:48
  • @Shawn: the empty string approach seems to work – James A Mohler Dec 20 '18 at 22:58

1 Answers1

3

FROM ABOVE COMMENTS:

CF2016 didn't do named parameters. That started with CF2018. So you'd have to take out the names and pass something in the 3rd and 4th position. Normally you can just pass the normal default values. I'm not sure what those are for this tag in CF2016, but the F2018 doc http://cfdownload.adobe.com/pub/adobe/coldfusion/2018/publicBeta/NamedParametersColdFusion2018.pdf seems to indicate the defaults are both empty strings.

Try

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

EXAMPLE:

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>
Shawn
  • 4,758
  • 1
  • 20
  • 29