CodiClone
CodiClone

Reputation: 141

IBM Cloud Functions - Set a global variable

I'm looking at the documentation, but I find nowhere an information for setting a global variable. We know that the Cloud functions are stateless code snippets, but I want somehow to integrate a global variable which can be changed by an action, read by another one and remain with the last state (true/false).

Is there any way for achieving such functionality?

Upvotes: 0

Views: 153

Answers (1)

data_henrik
data_henrik

Reputation: 17176

Function invocations are stateless, so that means there are no global variables. As stated in the comments, you could utilize a database to store state information.

Since you only want to avoid calling an API too often and not have a database, the only other option I see is to modify the action parameters. Utilizing the Cloud Functions API you could update the action itself and switch a parameter from false to true. I would not recommend it.

Upvotes: 0

Related Questions