Global variable or in memory storage

Global variable or in memory storage

  
Hi,

We have a requirement to store specific request processing information. Each request will be executing multiple Actions. Each action would be processing the request and have request specific information. Now we need to capture all the the information from multiple actions and send back along with response. Is there any way to implement this requirement in agile platform. the data should not be stored  as per the requirement.

To implement the above requirement I am thinking about to have a global variable to be used across multiple actions, however i could not find a way to declare global variable.

The other way of implementing is create a local variable and pass the value as a parameter to the invoking action and return the value.

Is there any better approach ?

any kind of help or insight is appreciated.


Thanks 
Md Ghouse G.
Global variables are usually a bad idea :)

If you're processing something based on some data that evolves with the processing, one of the best approaches you can take is to have an input on each of your actions for that global variable, and (if there is the possibility of that value being changed) having an output on each action with the new value for that piece of data.

There are also other approaches you can take. Session variables are visible to all the requests in one session and there is builtin concurrency control on the part of the OutSystems Platform regarding session requests. However, these values get written out to the database so they don't meet one of the requirements you stated.

All in all, without further details on the specifics of what you want to do, it's hard to devise a general approach to the problem you describe. In particular: why do you want a better approach than "pass the value as a parameter to the invoking action and return the value" ? Why is this not good enough?
Could not agree more with Ricardo...
Keeping in mind factors such as security and performance, you should use by default the way described by Ricardo.
Just as a note/curiosity, you can take a look at this article to see some of the problems related to the global variables (except rare exceptions).

Kind Regards,
G.M.

Hi 
Thanks for the reply. Does outsystems have the concept of memory DB or cache which can be used to store the information temporarly. similarly does outsystem support different scopes like request, application etc to store information.

Thanks 
Md Ghouse G



We use local variables to store information which is relevant to a given request / action / screen.

We use Site Properties to store information which is shared in all the application.

We use Session variables to store information which is relevant for a user's session.
Ricardo Silva wrote:
We use local variables to store information which is relevant to a given request / action / screen.

We use Site Properties to store information which is shared in all the application.

We use Session variables to store information which is relevant for a user's session.
 Nice summary about this issue!! :)
Three sentences => Three facts
 
Hi,

In our case the information is very huge and  go into MB. So for this scenario, as per my understanding can't use any of the above. so looking for alternative approach. Any suggestion is welcome.


Thanks 
Md Ghouse G
Hi MD Guduru,

You can write an extension that will implement an in memory cache that you can use in your action. You can then have a parameter in your actions and use that to reach the cache. Following that pattern, you could have an action in your extension that would give you a reference to that object given a key, that would be created on the start of your processing. See the StringBuilder from system for a pattern on this.

It seems to me that, per your description, ou would have a webservice that would be called and that would be then processing data as you describe.

If at the start of your webservice you simulate a login, and at the end a logout, event the key in session will be gone.

Hope it helps.
Pedro
RecordList is pass by reference, You could add the object to a recordlist and refer to the first node of it which is pass by reference. Could someone from outsystem validate this approach interms of performance. As the Object which we are using is pertty huge say 1000 elements in an xml(Structure) , assume it to be of size 100kb. I presume that each call to an sub action consumes 2 times of actual size which is 200 kb, as it is being nested the sub action can invoke another sub sub action and it should going to STACK, which inturn consumes another 100kb, Hence I believe adding the base object to an RecordList and passing by reference should be working on the same object and consumption is 100kb.
Hi Vasanth,

In niether cases it would take the 100k space in stack. Everything is implemented as classes (in the Java version), so you can do the stack math with just pointer sizes.
I am not clear, Say there are 5 nested actions, A1 calls to A2 calls to A3 calls to A4 calls to A5.. all are taking one argument X1 and respond the same X1 back. On the pass by value approach when an X1 reachs to A5, we should 5 version of  A1-X1, A2-X1, A3-X1, A4-X1, A5-X1, Changing something on A5-X1 will not affect the prior versions, it means we have consumed 5Times of memory isn't