Cache
Cache stores a value under a key for a limited time, so later runs can reuse it instead of repeating the work.
Screenshot placeholder
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
| Field | What it does | Notes |
|---|---|---|
| Cache key template | The key the value is stored under | A Jinja2 template. Placeholder: {{ input.user_id }}_{{ input.query }} |
| Operation | What the node does | Get, Set, Delete or Get or Set (default) |
| TTL (seconds) | How long the value is kept | Minimum 0, steps of 60. Default 3600 |
| Output key | The key the result is stored under for later nodes | Placeholder 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.