ibm-cloudibm-cloud-functions

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?


Solution

  • 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.