> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tensorlake.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Cache dependencies and build outputs

> Reuse repository caches across workflow runs without a cache upload action.

Point your build tools at `TENSORLAKE_CACHE_DIR` to reuse dependencies and build outputs across workflow runs.

## Configure a cache directory

Set your tool’s cache directory before building. For Rust, write `CARGO_TARGET_DIR` to `GITHUB_ENV`:

```yaml theme={null}
- name: Configure build cache
  shell: bash
  run: |
    cache_root="${TENSORLAKE_CACHE_DIR:-$RUNNER_TEMP}"
    echo "CARGO_TARGET_DIR=$cache_root/cargo-target" >> "$GITHUB_ENV"
- run: cargo build --locked
```

Use these variables for other tools:

| Tool              | Environment variable | Directory under the cache root |
| ----------------- | -------------------- | ------------------------------ |
| Cargo compilation | `CARGO_TARGET_DIR`   | `cargo-target`                 |
| npm downloads     | `npm_config_cache`   | `npm`                          |
| pip downloads     | `PIP_CACHE_DIR`      | `pip`                          |
| Go modules        | `GOMODCACHE`         | `go-mod`                       |
| Go build outputs  | `GOCACHE`            | `go-build`                     |

No `actions/cache` step is needed. See the complete [language workflow examples](/github-actions/workflows).

## Cache scope and persistence

Jobs and branches share a cache within the same project, GitHub connection, and repository. Use tool-supported locking or separate directories for concurrent writers, and keep secrets out of the cache.

Cache changes persist after a job finishes; forced termination can discard recent writes. Use GitHub artifacts for outputs you need to keep.
