Sam Farmer

Growing up I never imagined I would play bass guitar for the Dave Matthews Band. And indeed it never happened.

CF Dude, What's in the cache?

March 28, 2011

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:

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>

1 Comment

Hi Sam, I'm a community curator for a popular developer website with over 500,000 registered users. I was looking around the web for ColdFusion bloggers, and yours was exemplary. We're hoping to resuscitate our ColdFusion community, and we're recruiting the best ColdFusion bloggers to help us. Our featured bloggers generally experience increased traffic to their site. I'm also commissioning some paid articles on CF topics. Let me know what you think. -Katie-

By: Katie McKinsey 04/04/2011 12:43 PM
Some comments have been lost over the years due to moving hosts.

More


More blog entries that I have written.

Code coloring by PRISM.