GetUser(), CheckRole() usage & cost, what are the best practice

GetUser(), CheckRole() usage & cost, what are the best practice

  

Is there a cost associated with calling GetUserId() and CheckRole() multiple time with the same properties on a UI interface or servicer action?  

A.  Use GetUser() always or execute once and cache the output?

B.  Use CheckRole(StaticRole, <answer from A>) always or execute once and cache the output?

For example in TSQL, when the GetDate() method is referenced multiple times in a query the method is only executed once internal with the output being propagated to all other references of GetDate() in the given sql statement.  Is OutSystems doing something similar with the built in User methods?

Hey Erik,

the platform caches that output values for you.


Best regards,

Ricardo Saraiva wrote:

the platform caches that output values for you.

Thanks Ricardo, your job title of OutSystems Senior Magician is fantastic!


Hello Erik

I'm not sure I fully understood your question, but in OutSystems, if you use the CheckRole and GetUser action in an action (both User and Screen Action), the result is available throughout the "lifecycle" of the action. What I mean by this is, if we use CheckRole or GetUser at  the beginning of an action, the result can be called how many times you desire inside that action and use it on the screen

Regards,

Ângelo

Hello Erik

I'm not sure I fully understood your question, but in OutSystems, if you use the CheckRole and GetUser action in an action (both User and Screen Action), the result is available throughout the "lifecycle" of the action. What I mean by this is, if we use CheckRole or GetUser at  the beginning of an action, the result can be called how many times you desire inside that action and use it on the screen

Regards,

Ângelo

erik berg wrote:

Thanks Ricardo, your job title of OutSystems Senior Magician is fantastic!

That's what we all do with OutSystems, right? :D


Ângelo Sousa wrote:

Hello Erik

I'm not sure I fully understood your question, but in OutSystems, if you use the CheckRole and GetUser action in an action (both User and Screen Action), the result is available throughout the "lifecycle" of the action.

My question is really does OS internally optimize the CheckRole and GetUser methods in a server method execution chain, such that OS:

  1.  Only executes these methods once per unique parameter.
  2.  OS internally caches the the method results,
  3.  Subsequent encounters with the methods in the same server execution call chain use the cached values.

To expound on the server method execution chain, if OS is performing caching, that caching is more than likely at a per module level.  Ideally it would be at layer level per four layer canvas, but the OS four layer canvas at this point is a pattern, not a framework.  I am thinking in the future caching will be done at the container level.

Caching the CheckRole() function could be a very bad idea. When you revoke someone's rights, you want that to have effect immediately rather than only after the cache was invalidated. That said, the platform probably only caches it for a very limited amount of time.

I my opinion Tim make a point. The revoke of someone is rights must be immediate!!