Skip to main content
Version: 10 - Vanillekipferl

Caching

Caching returns the output value of a previous run execution when it was within a defined time-range.

Use Cases

Use caching

  • When reading data from a third-party system is slow or expensive.
  • When the data returned changes infrequently, but is accessed frequently.

Concept

The cache feature is implemented as a Wrapper.

Importing the Wrapper bundle will provide you with a wrapper called cache.

When the cache wrapper is attached to a connector or flow, it will search for previous successful executions of that connector or flow within a configurable timeframe. If any execution is found, the output value of that execution is returned. Otherwise the child execution is started normally and its output value is returned.

As all wrappers, the cache wrapper can be statically attached and configured. Please refer to Static Wrappers for more information.

Alternatively, the cache wrapper can be dynamically attached and configured. Please refer to Dynamic Wrappers for more information.

note

The cache wrapper provided by Engine is considered an example which can be extended or modified to your needs.

note

The search for previous executions is performed using the connector or flow and the name of the execution, if given.

Parameters

Refer to the cache wrapper for its parameters.

Examples

example

Using a connection with caching

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
# We connect to <name-of-a-connector>.
# If there is any previous execution of the connector within the last 60 minutes,
# the output value of the previous execution is returned immediately
# without connecting to the external system.
this.using(
'cache',
max_age_minutes=60,
).connect('<name-of-a-connector>')
return this.success('all done')
example

Caching named connections. Although both caches use the same connector each will receive the output value of the corresponding previous execution as determined by the name of the previous execution.

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution, inputs: dict):
# The cache will return the output_value of the last successful connection
# to <database> with the name "fetch data"
data = this.using(
'cache',
max_age_minutes=60,
).connect(
'database',
name='fetch data',
).get('output_value')

# The cache will return the output_value of the last successful connection to
# <database> with the name "write status"
result = this.using(
'cache',
max_age_minutes=60,
).connect(
'database',
name='write status',
).get('output_value')

return this.success('all done')

Learn More

Wrappers
Wrapper bundle
Import / Export and Upload