Widgets/Storage

Event Cache Widget

Event Cache Widget

A "Storage" type widget. Event Cache Widget allows data to be stored and retrieved only to widgets in the same execution path. Each event in a recipe execution has a unique eventId, which is used (together with recipePoolId and a scope name) to store and retrieve event data for that specific event session.

The widget provides a scoped caching mechanism where data can be stored under different scope names (e.g., 'user', 'admin', 'config'), allowing multiple data types to be cached for the same event context. This enables widgets in the same execution path to share data without affecting other event sessions.


How It Works

When an event flows through a recipe, it receives a unique eventId. Event Cache Widget uses this eventId and a user-defined scope name to create a unique cache key. This ensures that:

  • Data stored in one event session is isolated from other event sessions
  • Multiple widgets in the same execution path can access the same cached data
  • Different scope names allow storing multiple values for the same event

The cache automatically expires entries older than 5 hours. Expiry checks occur whenever an event arrives at Event Cache Widget, ensuring stale data is cleaned up during normal operation.

 

Inputs


  • read (DataType: Anything) When the read port is invoked, Event Cache Widget checks if data exists for the current event ID and scope name. If data is found, it transmits the stored value to the data output port. If no data has been written before, it transmits to the empty output port instead.

  • write (DataType: Anything) The write port stores the incoming event data internally under the current event ID and scope name. This operation does not produce any output event. The stored data can be retrieved later using the read port.

  • clear (DataType: Anything) The clear port removes the cached data for the current event ID and scope name. This operation does not produce any output event. Only the data for the current scope is removed; other scopes for the same event ID remain unaffected.


Outputs

  • data (DataType: Anything) The data port transmits the cached data when the read port is invoked and data exists for the current event ID and scope name. The data type matches whatever was originally written to the cache.

  • empty (DataType: Anything) The empty port is triggered when the read port is invoked but no cached data exists for the current event ID and scope name. This allows you to handle the case when the cache is empty and take appropriate action (for example, fetch data from an external source or use default values).


Custom Settings

  • Scope Name — The scope name input sets the label for cached data. For example, with "user", event data is stored under a key derived from (recipePoolId, eventId, "user"), so multiple values can coexist for the same event context under different scope names.

If the scope name is left blank, the widget uses "default" as the scope name.


Configuration

 

Examples

Store user data in Event Cache and reuse it later in the same execution path

This example uses two Event Cache Widget instances with the same user scope to write parsed user data and read it back later in the same run. See In this example for each step.


Drag the example onto the workspace to explore and experiment!



In this example:

  1. The Button Widget starts a Sequence Widget that:

    • First triggers the Text Widget, which contains a JSON string with the user data (name: "John", surname: "Doe")
    • Then triggers the second Event Cache Widget on its read port
  2. When the Text Widget runs, it sends the JSON string to Text to Object Widget, which converts it into an object and passes it to the first Event Cache Widget's write port using the user scope. The value is stored for the current event, and the write operation does not transmit a follow-up event.

  3. On the Sequence Widget's second step, the second Event Cache Widget uses the same user scope to run read:

    • If cached data exists, it transmits the stored object on data
    • The Template String Widget uses that object to build a greeting such as Hello John Doe! with {{input.name}} and {{input.surname}}
    • A Text Widget displays the final message

 

📌 Notes

  • Cache entries are automatically expired after 5 hours if the clear port is not called
  • Multiple scope names can be used to store different data types for the same event session
  • The clear operation only removes data for the current scope; other scopes remain unaffected

 

Glossary

Execution path

The chain of widgets that process the same event through a recipe, so Event Cache Widget data written in that path can be read by other widgets on that path.

Event session

A single event's processing in a recipe run, identified by a unique eventId (and related pool context), used to isolate cached values from other runs.