RE: [coldbox:16992] Caching

Do you only need the result model for the duration of that specific method? If so, wire in WireBox and call getinstance() and just store it in the local scope.

If you need the result model to hang out for the entire duration of the request and be hit by muliple files (kind of like the request scope), then tell WireBox to place it in the request scope, and then call it the same way I suggested above. WireBox will create it the first time you need it, and keep it in a request scoped storage just for your request. It will had you back the same object every time you ask for it for the duration of that request. At the end of the request, it will be destroyed.

If you are using explicit mappings in your binder config (/config/WireBox.cfc) then it would look like this:
map(“result”).to(“path.to.result”).into(this.SCOPES.REQUEST);

If you are using implicit mappings via scan locations, or mapDirectory(), then just put this annotation in your CFC. (This will actually work with explicit mappings too)

component scope=“request” {
}

Read up here: http://wiki.coldbox.org/wiki/WireBox.cfm#Scope_Persistence_Annotations

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Brad,

I needed it to persist in other areas of the application so I wrote two functions into the result to clear and exceptions or errors and run them before I start the rest of the userValidator function so I’m starting with an empty object. That seems to have fixed my problems for now, but I will read up on your suggestion.

Thanks,
Rob