I need a reality check - and hopefully an explanation (if my reality is wrong).
The way the CF application framework evaluates things is this (my understanding) - request is passed to cfserver
cf finds an application.cfm or cfc (based on traversing rules)
application.cfc executes (if found)
the THIS scope is set (a series of application specific vars can be set here but
some are required - such as "applicationTimeout" - then a series of events takes place -and methods fired if needed.
-- onApplicationStart()
----onSessionStart()
------onRequestStart()
etc.
so my questions
1) The THIS settings happens on EVERY page request - before anything else?
2) If I set an application variable, in onApplicationStart() - it is available in any process that happens after that - AND should persist in memory for the length of applicationTimeout() - correct?
3) so if I do something like this...
if ( isdefined("application.myvar" ) { this.something = application.myvar; }
it SHOULD work on any page request after the initial request that started the application scope.
however it doesn't appear to do so.
my reason for asking is this - there are some interesting application lever settings that need to be set in the THIS scope... a few of them could be 'intensive' (at least form the perspective of executing on EVERY request - so I want to do them only ONCE, set a structure in persistent mem, and then have those available as THIS.
am I making some wrong assumptions?
thx
The ColdFusion Application.cfc documentation has this tidbit of knowledge:
When a request executes, ColdFusion runs the CFC methods in the following order:
- onApplicationStart (if not run before for this application)
- onSessionStart (if not run before for this session)
- onRequestStart
- onRequest/onCFCRequest
- onRequestEnd
The onApplicationEnd, onSessionEnd, and onError CFCs are triggered by specific events.
The overall request order has (at least) two more steps.
0: execute all code in
cfcomponent
that isn't in acffunction
0.5: run the equivalent of thecfapplication
tag for creating the Application
As such the answers to your questions are:
this
scope, but will not take effect in step 0.5.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With