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
InVision App - Prototyping Made Beautiful With Prototyping Tools Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 21, 2012 at 1:58 AM
Updated: Converting A ColdFusion Query To CSV Using QueryToCSV()
Hi Ben, why do you need to have so many double quotes when adding the field and field name to the row data? ----------------------------------------- <cfset LOCAL.RowData[ LOCAL.ColumnIndex ] = ... read »
AXL
May 21, 2012 at 1:24 AM
URL Rewriting And ColdFusion's WriteToBrowser Image Functionality (CFFileServlet)
@Mounir, Open your lower case URL Rewrite rule and add the following condition. Condition input: {REQUEST_URI} Check if input string: Does Not Match the Pattern Pattern: ^/CFFileServlet/_cf_ca ... read »
May 20, 2012 at 4:28 AM
Understanding The Complex And Circular Relationships Between Objects In JavaScript
@Will Vaughn I tried your javascript example but got this error:- foo.print is not a function ... read »
May 19, 2012 at 5:37 AM
A Graphical Explanation Of Javascript Closures In A jQuery Context
Thanks for this article, but I fear you missed an important point. If variables in the outer context change, these changes affect the inner anonymous functions as well. That means: if you change the ... read »
May 18, 2012 at 3:39 PM
Parsing CSV Data With An Input Stream And A Finite State Machine
Can you use file upload button with this? and read live? or does the file have to already be on the server saved? ... read »
May 18, 2012 at 1:06 AM
VIRGO (Aug. 23-Sept. 22): Dead On The Money!
A friend of mine and I were arguing about astrology and she told me that he believes in astrology. She hasn't provided me with any evidence that the belief makes any sense to me. She she been telling ... read »
May 17, 2012 at 11:32 PM
Using ColdFusion to Handle 404 Errors (Page Not Found) On Development Server
Very easy the configuration. I read a lot pages and I can't find the solution. I open the administrator and change this Administrator/server settings/Error Handlers/Missing Template Handler and p ... read »
May 17, 2012 at 3:13 PM
LOCAL Variables Scope Conflicts With ColdFusion Query of Queries
I never cease to be amazed that almost EVERY random CF issue I come across lands me on your site. Thank you for documenting your findings for the world. ... read »