DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > CF Dude, What's in the cache?

CF Dude, What's in the cache?

Sam Farmer user avatar by
Sam Farmer
·
Apr. 25, 11 · Java Zone · News
Like (0)
Save
Tweet
6.93K Views

Join the DZone community and get the full member experience.

Join For Free

Over the weekend I needed to see what was in my cache. I whipped up a quick script to list everything in cache and from there:

  • be able to remove an item
  • view the content of an item (limited to top 10 records)
  • view the metadata of an item.
I've included the code below.
<cfscript>
writeOutput('<h2>CF Dude, What''s in the cache?</h2><div><a href="#cgi.script_name#">Reload</a><br><br></div>');

param name="url.do" default="";

switch (url.do) {
    case "remove":
        cacheRemove(url.item);
        writeOutput("<div style='color: green; font-weight: bold'>Removed #url.item#</div>");
    break;
    case "view":
        writeDump( var=cacheGet(url.item), label="Cache contents of: " & url.item, top=10 );
    break;
    case "meta":
        writeDump( var=cacheGetMetadata(url.item), label="Metadata for: " & url.item );
    break;
}

incache = cacheGetAllIds();
arraySort(incache,"textnocase");
</cfscript>

<cfoutput>
<h3>Cache IDs</h3>

    <table cellspacing="4">
    <cfloop array="#incache#" index="c">
        <tr>
            <td>#c#</td>
            <td><a href="#cgi.script_name#?do=remove&item=#c#">remove</a></td>
            <td><a href="#cgi.script_name#?do=view&item=#c#">view</a></td>
            <td><a href="#cgi.script_name#?do=meta&item=#c#">meta</a></td>
        </tr>

    </cfloop>
    </table>

<h3>Cache Properties</h3>
<cfdump var="#cacheGetProperties()#">
</cfoutput>


Collaborative filtering Cache (computing)

Published at DZone with permission of Sam Farmer, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Why Performance Projects Fail
  • Implementing RBAC Configuration for Kubernetes Applications
  • How to Leverage Method Chaining To Add Smart Message Routing in Java
  • Ultra-Fast Microservices: When Microstream Meets Payara

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo