Special considerations for building master process flows - caches

Introduction

Currently, you can replace company caches as part of virtual environment configuration, but not:

  • flow-type caches

  • 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

Cache type
Can be replaced in VE config?
Can be used in master process flows?
Cache key notes

Company

Yes

Yes

Keep in mind that whilst a company cache can be replaced, the cache key cannot. As such, you should ensure that the given cache key in your master process flow utilises variables to ensure that it's unique at runtime - please see Referencing variables for unique cache keys, below.

Flow

No

Yes

Although flow caches cannot be configured as virtual environment replacements (currently), you can still include them in a master process flow.

It's important to ensure that the given cache key in your master process flow utilises variables to ensure that it's unique at runtime - please see Referencing variables for unique cache keys, below.

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.

For further information, please refer to Generating dynamic cache keys with variables.

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.

1

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.

Don't forget to deploy the virtual environment configuration if you make changes.

2

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

You can specify the environment variable value on its own, or combined with static text and/or other variables. For example:

{{environment.variables.uniquecachekey}}-customers

or

{{flow.variables.timeperiod}}-{{environment.variables.uniquecachekey}}-customers

Last updated