seancorfield
rc
or `local`/`var` scope variables only. The variables
scope of a controller should only be used to cache global state (like an in-memory copy of a fixed lookup table or some such) and should either be initialized in the constructor method init()
via dependency injection, or with careful locking as if dealing with application
scope.Charles Robertson
11/03/2022, 9:40 AMvariables
scope in services?
https://github.com/framework-one/fw1/blob/develop/examples/userManager/model/services/user.cfc
Can I assume that the:
variables.users = {};
Used here, is to store every user bean
that is created, updated or deleted, into a cached Struct? The idea, being that it is quicker to do an in-memory look up than a DB look up?
And here, anyone with access to the user service, can add/update this Struct.
I can see now, that this makes sense.
Unfortunately, I should have realised a long time ago that this approach, would not suit my objective, of returning a pagination based list.
My objective requires that different users might see a different user list, for a different page.
In my case, the variables
scope is not the correct mechanism for storing my list.
My list is a subset of users, rather than all users.seancorfield
seancorfield
seancorfield
seancorfield
variables.users
is like "global storage". When I rewrote the example in Clojure, I used an actual database instead (mind you, Clojure doesn't have objects anyway because it's a functional language).Charles Robertson
11/03/2022, 4:08 PMsalted
12/01/2022, 6:41 PM