RE: [contentbox-version] Handler caching, inject object problem

Curt and Luis answered this nicely, but I love a good analogy.

Imagine if Walmart only had one shopping cart for the entire store and everyone in that store had to share it. That would work fine as long as a separate physical Walmart was built for every person in your city. Then there would only be one person in each store. This is what what happens when you turn off handler caching and the handlers are re-created every request. In reality though, there’s only one Walmart in your city and it can’t have a single shopping cart-- it needs to have the ability to create a new cart every time a new person walks through the door. (Well, object pooling technically :slight_smile: Likewise, your handler needs to have the ability to create a new instance of your transient that not stored in any scope which lives longer than session. This can be done by injecting a reference to WireBox itself and calling wirebox.getInstance() ever time you want a store object, or injecting a provider and calling provider.get() every time you want an instance. (A provider simply turns around and calls getInstance() on WireBox so it’s basically the same thing).



ColdBox Platform Evangelist
Ortus Solutions, Corp

ColdBox Platform:

Brilliant, I were laughing my head off :smiley:

After getting the reference to “Scope widening” from Curt I could fix it immediately. Now we do not need to set up a Walmart for every user :slight_smile: