Skip to main content

Overview

The cache feature enables workflows to store intermediate task results, enhancing efficiency and reducing redundant computations.

Configuration

  • Configure caching at task level using the cache property.
  • Enable caching with the enabled field.
  • Specify the cache location with the path field. Jinja templates can be used to dynamically generate paths.
  • The cache format can be sql or json, depending on the task type (whether it generates SQL or JSON output - JSON is commonly used for structured output from the agent).

Core Components

Example

Referencing Cached Queries

You can cache generated queries in workflows and reference them in subsequent tasks using Jinja. For example:
In this example:
  • The report task generates a query and caches it in output/agent.sql.
  • The metrics loop references the cached query in the execute_sql task.

Benefits

  • Efficiency: Saves time by reusing cached results.
  • Reusability: Cached data persists across runs.
  • Debugging: Provides snapshots of intermediate outputs.
  • Task Interoperability: Cached queries can be referenced in subsequent tasks, enabling seamless integration between tasks.

Best Practices

  1. Use descriptive, unique paths to avoid conflicts.
  2. Include the workflow name or a unique identifier as part of the cache file path to ensure clarity and avoid overwrites.
  3. Regularly clean up outdated cache files.
  4. Validate cached results for consistency.
  5. Add the cache folder to .gitignore to avoid committing cached files.

Workflows

Agents