Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7665503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:35:04+00:00 2026-05-31T14:35:04+00:00

I’ve been blind sided by the change from CF8 to 9 where write to

  • 0

I’ve been blind sided by the change from CF8 to 9 where write to disk caching is no longer possible without creating a custom cache or some other drastic workarounds that are not worth the effort.

At this time I’ve abandoned trying to convert the application to uphold, if possible, the same method of writing the contents of a cache file into a static cfm file. I’m more curious now that I’ve dug into it a bit deeper. I’m looking for someone that has more experience with this than myself.

What I’d like to understand or know how to do with template cache is:

  1. Be able to target a template in default or custom cache and flush it without clearing the entire cache.
  2. View or parse the contents of a particular cached template either out of curiosity or debug approach.

This was the code I was tooling with, requires CF 9.0.1 due to some cache memory functions that are not available in 9.0 due to the addition of EhCache 2.0 I believe.

<cftry>
        <cfcache action='serverCache' timeout='#CreateTimeSpan(0,0,0,10)#' stripwhitespace='true' 
                 usequerystring='true'>
            Stuff to cache.
            <br/>
            <cfoutput>#now()#</cfoutput>
            <br/>
        </cfcache>

        <!--- Get the cached contents --->
        <cfdump var="#cacheGetProperties()#">
        <cfdump var="#getAllTemplateCacheIds()#">
        <!---Locate a single cached item --->
        <cfscript>
            cacheArray = getAllTemplateCacheIds();
            WriteOutput("Before<br/>");
            for(i=1;i LTE ArrayLen(cacheArray);i=i+1)
            {
                writeOutput(cacheArray[i] & "<br/>");
                if(FindNoCase(scriptPath, cacheArray[i]))
                {
                    //expect only to find min and max one per string so no need to worry about out of bounds
                    cacheIDSubStr =  REFind("[a-fA-F\d]{32}(?=_LINE:\d*$)",cacheArray[i],1,1);
                    cacheID = Mid(cacheArray[i],CacheIDSubStr.pos[1],CacheIDSubStr.len[1]);
                   //Failure to delete cache expected fireworks
                    //WriteOutput(cacheID&"<br/>");
                    //cacheObject = CacheGet(cacheID);
                    //CacheRemove(cacheID);
                    templateCache = cacheGetSession("template");
                      //Tooling around with the exposed guts of cacheGetSession
                    WriteDump(templateCache.getKeys());
                }
            }
        </cfscript>
    <cfcatch type="Any">

        <cfscript>
            writeoutput("Error:" & cfcatch.message);
        </cfscript>

    </cfcatch>
    </cftry>

No errors should exist, but it was edited from the original to post here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:35:06+00:00Added an answer on May 31, 2026 at 2:35 pm

    The secret is in the CF 9.0.1 function cacheGetSession(), along with the amending of the other functions to take a key as a parameter.

    The following code will only work in 9.0.1.

    Assuming:

    <cfcache action="serverCache" timeout="#CreateTimeSpan(0,0,0,10)#" stripwhitespace="true" usequerystring="true">
    Stuff to cache in the default store.
    <br/>
    <cfoutput>#Now()#</cfoutput>
    </cfcache>
    
    <cfcache action="serverCache" key="myCustomCache" timeout="#CreateTimeSpan(0,0,0,10)#" stripwhitespace="true" usequerystring="true">
    Stuff to cache in the 'myCustomCache' store.
    <cfoutput>#Now()#</cfoutput>
    </cfcache>
    

    Accessing the identifiers of the cache separately

    Default (Template):

    <cfdump var=#getAllTemplateCacheIds()#>
    

    myCustomCache:

    <cfdump var=#cacheGetSession('myCustomCache',true).getKeys()#>
    

    Reading the data of the custom cache

    <cfset keys = cacheGetSession('myCustomCache',true).getKeys() />
    
    <cfcache key="myCustomCache" action="get" name="dataInCache" id="#keys[1]#">
    
    <cfdump var=#dataInCache#>
    

    Flushing the custom cache independently of the default

    <cfset cacheRemove(keys[1],true,'myCustomCache')>
    

    Sadly, documentation is not at its best with regards to the functionality that snuck in with 9.0.1. Luckily, the CF userbase is good at digging this stuff out, namely Rob-Brooks Bilson, who has a number of great articles on CF and caching in general.

    Couple of caveats you should remember in working with the cache in this fashion:

    1. These calls tie to EhCache under the hood, which is Java, and may return NULLs if you try to access keys that don’t exist. Wrap your results in IsNull() to validate.

    2. cacheGetSession() is misleading (as Rob points out on his blog), you may think you are retrieving session-related cache data as it applies to your app, but that is not the case–it is server-wide, and you will see other cache’s keys in a share app environment.

    So, take care to flush the appropriate data…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I have a bunch of posts stored in text files formatted in yaml/textile (from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.