Reputation: 139
I'm working on a ColdFusion dynamic website. For this website, there are a lot of CFCs and a lot of functions within each CFC. Would it be more efficient to store an instance of the CFC in an application variable, then to instance each CFC separately on each page load.
For each page, at most 2 separate CFCs get called. I'm also interested in how performance will be effected when requests increase (Stress).
Thanks!
Upvotes: 1
Views: 161
Reputation: 3355
It depends. If the CFCs in question are singletons then yes, it's wise to instantiate them once and store them into the Application scope. As you get more experienced and your application grows you'll find that the best tool to manage object dependencies is ColdSpring, but for now just creating the object in onApplicationStart()
would be your best bet. If you are dealing with transient objects then you'd need to create the object per request.
Upvotes: 5