Special considerations for building master process flows - caches
Introduction
Currently, you can replace flow
and company
caches as part of virtual environment configuration, but not:
flow run-type caches
cache keys
The fact that you can't define these items as virtual environment replacements doesn't prevent you from using them in process flows - please see specific guidance below.
Cache type usage in virtual environments
Company
Yes
Yes
We recommend that you always replace company
caches in virtual environments, unless you have a good reason for not doing so. This ensures that caches are unique for each environment.
Keep in mind that cache keys are NOT replaced. Provided that you replace the company
cache in each virtual environment, this is not an issue - the cache in each environment will be unique.
If, for some reason, you do not take this approach, please ensure that the given cache key in your master process flow utilises variables to ensure that it's unique at runtime - otherwise, cached data from one environment may overwrite data from another. Please see Referencing variables for unique cache keys for more information.
Flow
Yes
Yes
We recommend that you always replace flow
caches in virtual environments, unless you have a good reason for not doing so. This ensures that caches are unique for each environment.
Keep in mind that cache keys are NOT replaced. Provided that you replace the flow
cache in each virtual environment, this is not an issue - the cache in each environment will be unique.
If, for some reason, you do not take this approach, please ensure that the given cache key in your master process flow utilises variables to ensure that it's unique at runtime - otherwise, cached data from one environment may overwrite data from another. Please see Referencing variables for unique cache keys for more information.
Flow run
No
Yes
Behind the scenes, each cache key for a flow run
cache is appended with a unique flow run id
- although you never see this in the dashboard, it does mean that these caches will never clash between virtual environments.
However, if required, you can reference an environment variable in the cache key name, so the cache key is immediately identifiable for each virtual environment. Please see Referencing variables for unique cache keys, below.
Referencing variables for unique cache keys
When data is added to a cache
, it goes into the given cache key
. So, if the add to cache shape in a master process flow is defined with a static cache key, this will be overwritten each time the flow runs in a virtual environment.
With this in mind, you must ensure that the cache key is unique. There are two approaches for this, depending on how you want incoming data to be cached:
Single-item payloads
If you want to (dynamically) create one cache key per record in the incoming payloads, you can define the cache key as a unique payload variable (e.g. [[payload.customer_id]
]). With this approach, you must be sure that any resolved variable values will NOT be seen in more than one environment - otherwise, cache keys will not be unique and may be overwritten.
Full payloads
If you don't want to cache single-item payloads (for example, you might want to store the entire incoming payload in a single cache key), you must reference an environment variable as part of the cache key name in your master process flow. To do this, follow the steps below.
Define a variable replacement in your virtual environment configuration(s)
Access the configuration for each virtual environment and define a replacement variable to be referenced as the cache key. The variable name should be the same in each virtual environment, but the value
must be unique for each environment - for example:

In this example, we've defined an environment variable
replacement named uniquecachekey
with a value
set to fr_sandbox
.
Reference the environment variable in your master process flow
Access the add to cache shape in your master process flow and add a reference to the environment variable created above - for example:

Here, we use environment variable syntax to reference the variable defined as a virtual environment replacement (in the previous step):
{{environment.variables.uniquecachekey}}
When this process flow runs in a virtual environment, the cache key resolves as whatever value is configured for the environment - for our example, this will be:
fr_sandbox
Last updated