What is Shared Memory
Shared Memory allows storing permanently single values, such as values of dataset cells or workflow parameters. Stored values can be accessed by any EasyMorph workflow. As a result, stored values can be shared across projects or modules of the same project. Unlike workflow parameters that don't change during a workflow run, values in Shared Memory can be created, changed, and deleted at any point of a workflow. Keep in mind, however, that Shared Memory is shared between all workflows executed on your machine, or in the current Server space. Therefore as soon as you change a value in Shared Memory, it changes for all workflows that are running at the same time.
From a technical perspective, values in Shared Memory can be viewed as global variables. Or, speaking even more technically, Shared Memory is a key-value store embedded in EasyMorph.
Shared Memory is a part of the repository, the same repository in EasyMorph that stores your connectors to databases, email services, and other applications. Keep that in mind if you switch to another repository because that would switch Shared Memory too. For EasyMorph Server, typically each Server space has its own Shared Memory (unless two spaces are configured to re-use the same repository). If you use a Server-hosted repository in your EasyMorph Desktop, that means you use Shared Memory from the Server too.
How does it work
Shared Memory can store many values. To distinguish one stored value from another, each value is associated with a uniquekey. For instance, if the "Test mode" key is associated with value "Yes", that basically means:
Test mode = Yes
You can think of keys as names of values in Shared Memory. To avoid ambiguity, all keys (names) in Shared Memory must be unique. Values associated with keys can be any.
Hint: To organize many keys, use slashes ("/") to create complex keys, for instance "Sales/Total/USD" or "Environment/Database/Last updated".
The "Shared Memory" action
Use the "Shared Memory" action to perform various operations with Shared Memory.
The action has the following commands:
- Remember — remember a value, i.e. save it to Shared Memory (or update it if it's already there)
- Recall — recall a value, i.e. retrieve it from Shared Memory
- Forget — forget a value, i.e. remove it together with its key
- List — lists keys (or a filtered subset of them) and their associated values
Use cases for Shared Memory
Shared Memory can be used in many cases, for instance:
- Configure environment (e.g. for development or production)
- Arrange incremental loads, e.g. you can store the most recent ID or timestamp
- Store short commonly used reference lists
- Pass values from one iteration to another in a workflow
- Store the value of a metric in the Catalog
Video: The 10-minute video below explains and demonstrates Shared Memory.