Highlighted

Application Objects

New Here ,
Sep 10, 2015

Copy link to clipboard

Copied

I have an object that I use to process address information.  Currently I'm instantiating per request, however, I'd like to move that into an application scope. My concern is that somehow this will adversely affect the my request or session level scope or that somehow if multiple requests occur that the request/session will crosswires somehow.

TOPICS
Advanced techniques

Views

431

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Application Objects

New Here ,
Sep 10, 2015

Copy link to clipboard

Copied

I have an object that I use to process address information.  Currently I'm instantiating per request, however, I'd like to move that into an application scope. My concern is that somehow this will adversely affect the my request or session level scope or that somehow if multiple requests occur that the request/session will crosswires somehow.

TOPICS
Advanced techniques

Views

432

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 10, 2015 0
Enthusiast ,
Sep 14, 2015

Copy link to clipboard

Copied

It sounds like you are worried about a threading issue -- without seeing the code if your cfc it is hard to say for sure, but in many cases you should be ok.

If the functions in your CFC only operate on the input arguments you should be fine, if you are doing a lot of read/write in the variables scope in your CFC if it is stored in the application scope, then you might need to lock access to those variables to avoid race conditions. The request scope is per request so there is no worry of issue there - session scope is automatically locked by CF, so you don't need to lock unless you are doing something like session.counter = session.counter + 1 (but that applies always not just in a CFC in an application scope).

This might provide some additional insight: Adam Cameron's Dev Blog: Overlapping requests will not cause a race condition in a CFM's variables s...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 14, 2015 0
BKBK LATEST
Adobe Community Professional ,
Sep 18, 2015

Copy link to clipboard

Copied

nak33 wrote:

Currently I'm instantiating per request, however, I'd like to move that into an application scope.

Do you wish to switch from request.someVar to application.someVar? If so, then user-sessions might indeed cross wires. For, if one user instantiates an application-scoped variable, he will have done so for all other current users of the application. It is best in these circumstances to show us the code.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 18, 2015 0