• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Application Objects

New Here ,
Sep 10, 2015 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

527

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
community guidelines
Enthusiast ,
Sep 14, 2015 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...

Votes

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
community guidelines
Community Expert ,
Sep 18, 2015 Sep 18, 2015

Copy link to clipboard

Copied

LATEST

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.

Votes

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
community guidelines
Resources
Documentation