Search Marketing ExpoLive Coverage
Recent Conference Articles:


Articles From Our Partners:



Conference Videos:

SMX: Tips, Tricks and Tools SMX: Tips, Tricks and Tools
They discussed their favorite tools as well as helpful SEO tips. Hear all about it only on WebProNews.

SMX: Barry Schwartz on Search SMX: Barry Schwartz on Search
Barry Schwartz of Search Engine Roundtable spoke with WebProNews at the SMX Seattle.

SMX: Michael Gray on Search Engines and Google SMX: Michael Gray on Search Engines
Michael Gray owner of AtlasWebServices.com talks about search engine users and the Google junkie.

Visit Videos.WebProNews.com for more

Web News

2007 Technology Impact Award Winners Announced
Known worldwide for its zero-energy solar powered LED lighting solutions, Victoria-based Carmanah Technologies walked away with the coveted Company of the Year Award at the 14th Annual Technology Impact Awards (TIAs) hosted by the BC Technology...

NHL partners with Sling Media Inc. for its upcoming...
The NHL has partnered with Sling Media Inc. for its upcoming video clip-sharing service, signaling a professional sports league's support for an emerging technology that has some media companies on...

ITU launches online resource for security standards
Canadian IT security professionals said they are receptive to an online resource launched by the International Telecommunication Union (ITU) that’s essentially a one-stop-shop for finding information on global IT security standards. The ICT Security...


06.08.07


ColdFusion 8: Admin API & Trusted Cache

By Raymond Camden

Along with cool tags and functions added in ColdFusion 8, there have also been some neat updates to the Admin API. If you don't know what the Admin API is - it is a set of CFCs that give you programmatic access to various administrator type functions.

One example is being able to list and create datasources. Today I want to show one of the new features in the Admin API under ColdFusion 8 - being able to clear individual files from the trusted cache.

One of the caching settings you can use within ColdFusion is the trusted cache. By turning this on, ColdFusion will parse your file one time, and will never parse it again. If you change the file, even to fix something small like a typo, you have to login to the Admin and hit the "Clear Template Cache" button.

Well the Admin API lets us do this directly from code. This existed even back in ColdFusion 7. But the problem is - when you just fix one file, why do you have to clear the entire cache?

Try a Better Way Today.
Try WebEx MeetMeNow -
Click Here

ColdFusion 8 updates the API so you can pass in a list of files. If you do, only those files are updated. This can be pretty darn useful. Here is a sample application I built that demonstrates this new API:

<cfoutput>
<form action="#cgi.script_name#" method="post">
Enter file name or directory: <input type="text" name="cachefile"> <input type="submit" value="Clear File/Folder from Template Cache">
</form>
</cfoutput>

<cfif structKeyExists(form, "cachefile") and len(trim(form.cachefile))>
   <cfset form.cachefile = trim(form.cachefile)>
   <!--- detect folder versus file --->
   <cfset filelist = "">
   <cfif directoryExists(form.cachefile)>
    <cfdirectory directory="#form.cachefile#" name="files">
    <cfloop query="files">
     <cfset filelist = listAppend(filelist, form.cachefile & "/" & name)>
    </cfloop>
   <cfelseif fileExists(form.cachefile)>
   <cfset filelist = form.cachefile>
  <cfelse>
   <cfoutput>
   <p>
   <b>You entered a file or folder (#form.cachefile#) that did not exist.</b>
   </p>
   </cfoutput>
   <cfabort>
  </cfif>

  <cfoutput>
  <p>
  Going to clear the following file(s) from the template cache:<br />
  <cfdump var="#listToArray(filelist)#">
  </p>
  </cfoutput>

  <cfinvoke component="cfide.adminapi.administrator" method="login" adminPassword="admin">
  <cfinvoke component="cfide.adminapi.runtime" method="clearTrustedCache" templateList="#fileList#">
</cfif>


It begins with a simple form asking you to name a file or a directory. One submitted, I check and see if you entered a folder. If you did, I do a cfdirectory to get the files in the folder. Once I have the files ready, I simply login to the Admin (note that I have hard coded the password here) and then run the clearTrustedCache function.

Pretty simple, right? There are a few updates I could do to this. I could make the cfdirectory tag recurse. I could also ask you for the ColdFusion admin password instead of hard coding it. I could even use Ben Forta's cool file browser.

If I were to package up this as something you could include in the ColdFusion admin (like SpoolMail), would folks use it?

Comments

About the Author:
Raymond Camden, ray@camdenfamily.com
http://ray.camdenfamily.com

Raymond Camden is Vice President of Technology for roundpeg, Inc. A long time ColdFusion user, Raymond has worked on numerous ColdFusion books and is the creator of many of the most popular ColdFusion community web sites. He is an Adobe Community Expert, user group manager, and the proud father of three little bundles of joy.

About DevWebProCanada
DevWebProCanada is for professional developers ... those who build and manage applications and sophisticated websites. DevWebProCanada delivers via news and expert advice New Strategies In Development.

DevWebProCanada is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITmanagementNews.com


-- DevWebProCA is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2007 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal 


archives | advertising info | news headlines | free newsletters | comments/feedback | submit article


Delivering IT Solutions DevWebProCanada News Archives About Us Feedback DevWebProCanada Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact