• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CF9 CFCache and ID

New Here ,
Jul 24, 2018 Jul 24, 2018

Copy link to clipboard

Copied

I'm running CF9 currently and trying to cache a fragment of a page.  This fragment is dependent on a region code, so I want to cache it with a different cache ID for each region.  The region code is in a variable.  So I am trying to do the following in the page:

<CFSET RegionID = 100>

<CFCACHE action="cache" ID="#RegionID#" timespan="#CreateTimeSpan(1,0,0,0)#">

This is the content I want to cache for Region: <CFOUTPUT>#RegionID#</CFOUTPUT>

</CFCACHE>

However it does not look like CF is using the value of the RegionID variable as the ID for the cached entity.  But it is actually using the string "#RegionID#" as the ID.  I can find this to be true by simply changing the RegionID value and I still get the same cached content as I had for the previous cache.  So I can not cache it for each region differently!

Am I doing something wrong?  A different approach perhaps?

TOPICS
Advanced techniques

Views

436

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 12, 2018 Aug 12, 2018

Copy link to clipboard

Copied

Cfcache's ID attribute identifies the object you are caching, not the region. You have to define the region beforehand.

Then pass the region-ID as a separate attribute. I would do something like

<!--- Define new region, with ID 'Region100'--->

<cfset properties=structNew()>

<cfset properties.name="Region100">

<cfset cacheSetProperties(properties)>

<!--- Object 'myCachedObjectId' is cached in 'Region100' --->

<cfcache action="cache" id="myCachedObjectId" timespan="#CreateTimeSpan(1,0,0,0)#" region="Region100">

This is the content I want to cache for Region100

</cfcache>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 19, 2018 Aug 19, 2018

Copy link to clipboard

Copied

LATEST

Hi @Brian Kondalski, did the above suggestion help?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation