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 21, 2013 at 7:46 PM
Using Plupload For Drag & Drop File Uploads In ColdFusion
No luck. At least I have uncovered the cause, URLScan 3.1. Here is what I see in the IIS log when a file is over 30mb. 2013-05-21 23:29:05 10.105.45.128 GET /plupload/assets/jquery/jquery-1.8. ... read »
May 21, 2013 at 6:12 PM
Using Plupload For Drag & Drop File Uploads In ColdFusion
Ben, I did not see you after Pete Freitag's Lockdown session at cfObjective but he said that IIS sets file size limits at 30MB by default which just happened to be the threshold for file size when ... read »
May 21, 2013 at 11:51 AM
Ask Ben: Parsing Very Large XML Documents In ColdFusion
Looking at my first ever XML document that I have to parse and put into MS SQL 2000 with CF8. I get it to list the desired Field name, many times over, and have a long list of this field name displa ... read »
May 21, 2013 at 9:25 AM
Turning Off and On Identity Column in SQL Server
you are awesome..i am lucky to get this blog between such a garbage one....Thanks, Prashant ... read »
May 20, 2013 at 4:38 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
@Dana, Your confusion is well founded, since this is a very confusing features. In fact, it ONLY works if you use array notation. Meaning, that this: arrayToList( query[ "columnName" ] ) ... read »
May 20, 2013 at 4:34 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
I was thinking chicken and the egg, I wouldn't have expected it to work in the valuelist going in I guess. Maybe I just need a beer, long day :) ... read »
May 20, 2013 at 4:29 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
@Dana, That's if you're trying to reference a specific row. In this case, we're trying to reference the entire query column as one cohesive value. So, you are correct that if you wanted to output a ... read »
May 20, 2013 at 4:24 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
I thought when you used array notation to reference queries you always had to have the row or it would throw a similar error as well? ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools