# Loading all cached data from a static cache key

## Introduction

This approach is the simplest - all incoming data is cached with a static cache key.&#x20;

## How it works

In the example below, all incoming customer records will be added to a cache named `ALLcustomers` and a static **cache key** named `customers`:&#x20;

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FwbTPliDTEy7QwaAsRQLA%2Fadd%20to%20cache%20a.png?alt=media&#x26;token=3bc57cd5-ab40-403c-941c-594d8e64b496" alt="" width="375"><figcaption></figcaption></figure></div>

When the data is cached, it's likely that the cache will include multiple records - 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%2F966M4YlXFnrNj7dquJgf%2Fadd%20to%20cache%20a2.png?alt=media&#x26;token=82637a4b-c6c3-4d9a-ac07-3cf500675d99" alt="" width="375"><figcaption></figcaption></figure></div>

To retrieve this cache, we simply drop a **load from cache** shape where required in the process flow and specify the same **cache** and **cache key** that were defined in the corresponding **add to cache** shape:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FwsTKTnAfkOhYtf1WUZuD%2Fadd%20to%20cache%20a1.png?alt=media&#x26;token=daa2e9be-fe85-4379-a971-0cfbb61536b4" alt="" width="375"><figcaption></figcaption></figure></div>

## Load a single, targeted item from a dynamic cache key

This approach assumes  The [load from cache](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/load-from-cache-shape) shape works as normal to retrieve cached data where the cache was created with a payload variable - you choose the cache name and key to be loaded:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FMvu0smgbvMZhv0uXxFhk%2Fload%20from%20cache%201.png?alt=media&#x26;token=fea99043-c6f1-4824-ab22-008fae4a3678" alt="" width="351"><figcaption></figcaption></figure></div>

However, the important point to consider is that the **cache key** that you specify here will have been generated from the payload variable that was specified when the cache was created.&#x20;

If a payload variable has been used to cache data, you would typically have included a [flow control shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/flow-control-shape) to create multiple payloads - for example:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FTMEexWiCezt5vyxScIZl%2Fmulti%20payloads.png?alt=media&#x26;token=9aee2de3-dc3f-423f-b6ea-6486d205c326" alt=""><figcaption></figcaption></figure>

So you will have multiple cache keys that can be loaded. To do this, you can add one [load from cache](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/load-from-cache-shape) shape for every `cache key` that you want to retrieve, specifying the required key in each case. For example:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FhLpyC674DchqXrO3v4Ee%2Fmulti%20payloads%202.png?alt=media&#x26;token=ad9a3ea0-749a-4f2d-8ae0-d7d7763364a2" alt=""><figcaption></figcaption></figure>

Alternatively, you can add a single [load from cache](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/load-from-cache-shape) shape and target specific cache keys by passing in the required ids.&#x20;

## Load multiple, targeted items from a dynamic cache key
