On Wed, Aug 3, 2011 at 4:41 PM, Eric Cobb wrote: > Let's say I've got an object cached in the application scope. The call to > this CFC is used throughout the site, which gets a lot of traffic. > Everything inside the CFC is var scoped, and it's completely encapsulated. > It's just runs a query, sets some variables, and returns the results. What > would happen if I were to "reset" the cache (by re-running cfset > application.myCfc = new com.blah) while someone was using that cached call?
The short answer: requests would use either the old instance or the new instance, so the only way you would get a problem is if the requests call multiple methods on the CFC (or one method multiple times) and expect the results to be consistent between calls. (If your application expects that consistency, put the cfc instance in the request scope in the onRequestStart() and use that throughout your application. The long answer is a bit more complicated and depends on your exact addressing scheme. Imagine the following (pseudo)code in some template: 1. <cfset application.myCfc = new utilCfc() /> 2. <cfset local.something[1].localReference = application.myCfc /> 3. <cfset application.myCfc = new utilCfc() /> 4. <cfset local.something[1].localReference.doSomething() /> 5. <cfset application.myCfc.doSomething() /> If you use patterns like this the code in line 4 and 5 may refer to different instances of utilCfc because in line 4 you are addressing utilCfc through an intermediate variable that may or may not have been updated by the code on line 3, while in line 5 you are definitely talking to the new instance that was created by line 3. Consistent coding is not just for readability :) Jochem -- Jochem van Dieten http://jochem.vandieten.net/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346505 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

