Single pool ColdFusion
Our ColdFusion application has stateless model objects. All the data I want I can get with one method call (it calls others without saving state).
Usually, methods query the database for data. All methods are read-only, so I don't have to worry about thread safety (please correct me if I'm wrong).
So there is no need to create object objects at all. I could call them statically, but ColdFusion doesn't have static methods - calling a method would mean instantiating the object in the first place.
To improve performance, I created single lists for each model object. So far this works great - each object is created once and then accessed as needed.
Now I'm worried that all requests for data will only go through one model object. Do I need? I mean if on my object I have a getOfferData () method and it is time consuming. What if a couple of clients want to access it? Will the second one wait for the first request to complete or is it executed on a separate thread? This is the same object.
Do I have to implement some sort of object pool for this?
source to share
The syntax pattern you are using will not cause the problem you describe. If getOfferData () is still working when another call to this function is called on another request, it will not result in a queue unless you do one of the following: -
- Use cflock to grant exclusive locking
- Get a queued connection to your database due to blocking / transactions
- You have too much work and you are using all the available parallel streams available for ColdFusion
So how you do it is good.
Hope it helps.
source to share