# Load from cache shape

## Introduction

The **load from cache** shape is used to retrieve a stored payload from an existing cache key (created from an [add to cache](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/add-to-cache-shape) shape).&#x20;

You might configure a **load from cache** shape in the same process flow as the original **add to cache** step or - if a cache was [added and set to company level](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/add-to-cache-shape#adding-an-add-to-cache-shape-to-a-process-flow) - you  might choose to load it in a different process flow.

{% hint style="info" %}
A single incoming payload for [any process flow shape](https://open.gitbook.com/~site/site_dIV1g/~/revisions/9dTvdvRJIRVZQXuBMMnJ/process-flows/building-process-flows/process-flow-shapes) should not exceed 500MB.

We recommend processing multiple, smaller payloads rather than one single payload (1000 x 0.5MB payloads are more efficient than 1 x 500MB payload!).

For payloads up to 500MB, consider adding a[ flow control shape](https://open.gitbook.com/~site/site_dIV1g/~/revisions/9dTvdvRJIRVZQXuBMMnJ/process-flows/building-process-flows/process-flow-shapes/standard-shapes/flow-control-shape) to batch data into multiple, smaller payloads. Payloads exceeding 500MB should be batched at source.
{% endhint %}

## Adding & configuring a load from cache shape to a process flow

To add a **load from cache** shape to a process flow, follow the steps below.

**Step 1**\
Find the point in your process flow where you want to load the payload from a cache - this could be at the very start of a process flow, or perhaps somewhere further down. &#x20;

**Step 2**\
Select the **load from cache** shape from the shapes palette:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Fo1DWOfgKm0Yt7E3Vub9e%2Fload%20from%20cache%201.png?alt=media&#x26;token=8dda76db-e027-4dbd-b776-47da1a794842" alt=""><figcaption></figcaption></figure></div>

**Step 3**\
Click in the **select cache** field and choose which cache you want to retrieve:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Fyk9hO5i2MBwgfjMgg8nH%2Fload%20from%20cache%201.png?alt=media&#x26;token=71e7e847-e8b4-4ca1-8f31-a649e2bdf5f9" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="info" %}
In this list, you'll find any caches that have been added to this process flow (via the [add to cache](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/add-to-cache-shape) shape), together with any caches that have been [added to other process flows and set to a cache level of company](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/add-to-cache-shape#adding-an-add-to-cache-shape-to-a-process-flow).
{% endhint %}

**Step 4**\
Enter the **cache** **key** that you want to retrieve - for example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F8BRMohQwOf5Pcphttpoz%2Fload%20from%20cache%202.png?alt=media&#x26;token=bfb0f5a1-71e2-4bd8-8583-173772a68930" alt="" width="375"><figcaption></figcaption></figure></div>

Your given **cache key** might be static or dynamic, depending on how the cache was configured in the corresponding [add to cache shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/add-to-cache-shape):

<table><thead><tr><th width="185.33333333333331">Cache key</th><th width="297">Summary</th><th>Example</th></tr></thead><tbody><tr><td>Static</td><td>Data is cached to the key exactly as it is specified. Typically used when your aim it to load the entire cache later in the flow (or in other flows).</td><td><code>orders</code></td></tr><tr><td>Dynamic</td><td>The cache key resolves dynamically based on a payload variable. Typically used when your aim it to load single or multiple items from the cache later in the flow (or in other flows). For more information please see our <a href="add-to-cache-shape/generating-dynamic-cache-keys-with-variables">Generating dynamic cache keys with payload variables</a>. </td><td><code>order-[[payload.0.id]]</code> OR <br><code>order-[payload.*.id]]</code></td></tr></tbody></table>

For detailed information about each of these approaches, please see [What cached data do you want to load?](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/load-from-cache-shape/what-cached-data-do-you-want-to-load)

{% hint style="info" %}
The cache key must be associated with an existing [add to cache](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/add-to-cache-shape) shape, either in the same process flow or (in the case of **company-level caches**) in another process flow.&#x20;
{% endhint %}

**Step 5**\
If you want this process flow to fail if for any reason this cache can't be retrieved, tick the **fail on cache miss** option:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FrP9Ull4wm8sU4q9tOLlk%2Fload%20from%20cache%203.png?alt=media&#x26;token=cef1c8fb-06a4-4a9b-84fe-ba91699fdbb7" alt="" width="375"><figcaption></figcaption></figure></div>

If you leave this option un-ticked, the process flow will continue to run if the cache can't be loaded.

**Step 6**\
If the cache that you're loading was [created](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/add-to-cache-shape) with the **save all pages** option toggled ON, you should toggle the **load all pages** option ON when loading this data:&#x20;

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FfCfvMVdy9aEpPyVigaHH%2Fload%20from%20cache%204.png?alt=media&#x26;token=5bfd1469-4fae-4947-8487-a472df50dcce" alt="" width="375"><figcaption></figcaption></figure></div>

{% hint style="info" %}
When paginated data is pulled from a [connection shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape), a payload is created for each page. If the **save all pages** option is toggled ON when a cache is created, the payload for each page is saved to its own **cache key** (with key names generated dynamically from a specified key and page numbers). If the **save all pages** option is toggled OFF, all pages are saved to a single **cache key**. For more information please see our [Cache pagination options](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/add-to-cache-shape/cache-pagination-options).
{% endhint %}

**Step 7**\
Save changes. The **load from cache** shape is added to your process flow, displaying the given **name** and **key** - for example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F9MbdswNxJvqTKfB2Ke40%2Fload%20from%20cache%205.png?alt=media&#x26;token=7d3ca848-5329-4b41-8bf0-b28d181b1a6e" alt="" width="312"><figcaption></figcaption></figure></div>

### Can I see the data associated with a load from cache shape?

Yes. As with any other process flow shape, you can view the associated payload for a l**oad from cache** shape after the process flow has run. To do this, click the shape's tick icon and then select the **payload** tab in the [run log panel](https://doc.wearepatchworks.com/product-documentation/process-flows/error-reporting-and-exception-handling/real-time-run-logs) - for example:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FaYYZcTbIxE22vNFEJuXa%2Fload%20from%20cache%20e.png?alt=media&#x26;token=d491b208-6bcd-42bf-a452-98c2e96adbb5" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/load-from-cache-shape.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
