Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
I am the chief technical officer at InVision App, Inc - a prototyping and collaboration platform for designers, built by designers. I also rock out in JavaScript and ColdFusion 24x7.
Meanwhile on Twitter
Loading latest tweet...
Ben Nadel at the ColdFusion Centaur And Bolt User Group Tour (Jun. 2009) with: Ye Wang and Simon Free

What Happens When I Cache Application.cfc Within The APPLICATION Scope?

By Ben Nadel on
Tags: ColdFusion

Pretty much nothing exciting :) But I wanted to try it to see if stuff would blow up. If nothing else, it proves that a new Application.cfc instance is created for every single page request. This test is super, ultra simple. Here is my Application.cfc ColdFusion component:

  • <cfcomponent>
  • <cfset THIS.Name = "App Cache Test" />
  • <cfset THIS.ApplicationTimeout = CreateTimeSpan( 0, 0, 5, 0 ) />
  • <!---
  • Here, I am creating a unique ID for this Application.cfc
  • just to help see if one instance is the same as another.
  • --->
  • <cfset THIS.ID = CreateUUID() />
  • <cffunction
  • name="OnRequestStart"
  • access="public"
  • returntype="boolean"
  • output="false">
  • <!---
  • Param an array in the APPLICATION scope to hold all
  • of our App.cfc instances.
  • --->
  • <cfparam
  • name="APPLICATION.Apps"
  • type="array"
  • default="#ArrayNew( 1 )#"
  • />
  • <!---
  • Append THIS application.cfc instance to our
  • cached array.
  • --->
  • <cfset ArrayAppend(
  • THIS
  • ) />
  • <cfreturn true />
  • </cffunction>
  • </cfcomponent>

Then, my index.cfm page merely CFDumps out the APPLICATION scope:

  • <!---
  • Dump out the APPLICATION scope. Put in a TOP 10 to
  • make sure nothing goes crazy.
  • --->
  • <cfdump
  • var="#APPLICATION#"
  • top="10"
  • />

After running that page a few times, here is what I get:


Application.cfc Caching In APPLICATION Scope  

As you can see, nothing exciting going on here. At least it didn't go kabooom!

Looking For A New Job?

100% of job board revenue is donated to Kiva. Loans that change livesFind out more »

Reader Comments

Post A Comment

You — Get Out Of My Dreams, Get Into My Comments
Live in the Now
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.