Docs
Sign in

Cache

Cache stores a value under a key for a limited time, so later runs can reuse it instead of repeating the work.

Screenshot to add: The Cache settings panel with Cache key template, Operation, TTL (seconds) and Output key.

When to use it

Use it when the same slow or costly result is needed again and again, such as a lookup that rarely changes.

Settings

FieldWhat it doesNotes
Cache key templateThe key the value is stored underA Jinja2 template. Placeholder: {{ input.user_id }}_{{ input.query }}
OperationWhat the node doesGet, Set, Delete or Get or Set (default)
TTL (seconds)How long the value is keptMinimum 0, steps of 60. Default 3600
Output keyThe key the result is stored under for later nodesPlaceholder cache_output

Inputs and outputs

  • One input at the top and one output at the bottom.
  • On the canvas the node is drawn as a generic node. The code does not show any extra outputs, such as separate "hit" and "miss" paths.

Example

Illustrative. Set Cache key template to {{ input.user_id }} and leave Operation on Get or Set. Each user's result is kept for an hour (the default TTL of 3600 seconds).

Tips

  • Make the key specific. Two different requests that share a key share one cached value.
  • The code does not say what a TTL of 0 means, so test it before relying on it.
  • Use Delete to clear a stored value you no longer want.