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

Posted March 14, 2007 at 11:39 AM by Ben Nadel

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(
  • APPLICATION.Apps,
  • 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!



Reader Comments

Oct 8, 2009 at 11:58 AM // reply »
2 Comments

thank you....


Post A Comment

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.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 20, 2013 at 10:21 AM
My Experience With AngularJS - The Super-heroic JavaScript MVW Framework
Is there any error logging and handling framework in angularjs, if not then in what way I can do this. ... read »
May 19, 2013 at 2:31 PM
My Experience With AngularJS - The Super-heroic JavaScript MVW Framework
It's funny really just how well that image describes the way I would imagine most people that go with angular for some project is. I have had a similar roller-coaster ride with it as well, but not qu ... read »
May 17, 2013 at 7:42 PM
HashKeyCopier - An AngularJS Utility Class For Merging Cached And Live Data
Ben - thanks so much for posting these Angular articles and findings, they've been a huge help towards learning one of the more 'complex' JavaScript frameworks out there (IMO). I have been using Angu ... read »
May 16, 2013 at 5:01 PM
UPDATE: Parsing CSV Data Files In ColdFusion With csvToArray()
Your code was the closest thing I've found to obtaining some direction for converting ISO fields to values that CF can translate properly. Thank you for posting! ... read »
May 15, 2013 at 6:07 PM
Making SOAP Web Service Requests With ColdFusion And CFHTTP
Ben, you once again saved my bacon at work. Thank you, thank you, thank you! ... read »
May 15, 2013 at 4:15 PM
What If All User Interface (UI) Data Came In Reports?
@Josh, Thanks! @Ben, I definitely recommend the David West book "Object Thinking" I've been quoting from. It goes deeply into the philosophy and history of OO programming. His breadth ... read »
May 15, 2013 at 11:36 AM
Ask Ben: Print Part Of A Web Page With jQuery
I found this helpfull when you need to keep (refresh) the original parent page after closing the iframe child print dialog (Hoping you're not using a form at this time so it won't submit again): On ... read »
May 14, 2013 at 7:13 PM
What If All User Interface (UI) Data Came In Reports?
@Jonah, If there's any books you'd recommend on the subject of domain modelling, I'd love to hear it. I just downloaded the free PDF of "Domain Driven Design Quickly". Figured I'd give it ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools