# Cache maintenance

## Introduction

You can [view](#cache-details), [create](#creating-a-cache), and [manage](#cache-details) all existing caches from the `data caches` page. To access this page, select `process flows` ➤ `caches` from the dashboard navigation menu:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F1mI2ppR2RhMeK64kLy67%2Fdata%20caches%200.png?alt=media&#x26;token=25ad82ca-7265-4ed3-9e26-6a63499bfa8a" alt="" width="229"><figcaption></figcaption></figure></div>

## Need to know

{% hint style="danger" %}
During routine platform maintenance, cached data may be cleared. While we make a best effort to retain data for up to 7 days, it could be cleared sooner. Please design your process flows accordingly.
{% endhint %}

## The data caches page

The `data caches` page is split into three sections: `flow run caches`, `flow caches`, and `company caches`:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FrErLtujH2xqEjFupHEQO%2Fdata%20caches%201.png?alt=media&#x26;token=6eb5ff84-424e-466b-93a6-2410c9459402" alt=""><figcaption></figcaption></figure></div>

Each cache is listed with the following details:

| Item                                                                                                                                                                                                                                                   | Summary                                                                                                                                                                                                                                                            |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Name                                                                                                                                                                                                                                                   | The name that was specified when the cache was created. Caches are created via the [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).  |
| Flow                                                                                                                                                                                                                                                   | For `flow` and `flow run` caches, this is the name of the process flow which is using the cache. This information is not shown for `company` caches, as the cache might be used in any process flow within a company profile.                                      |
| Created                                                                                                                                                                                                                                                | The date and time that the cache was created.                                                                                                                                                                                                                      |
| Last accessed                                                                                                                                                                                                                                          | The date and time that the cache was last accessed by a process flow. The cache may or may not have been updated with data at this time (even if there is no data to be added, the access date/time is logged).                                                    |
| Keys                                                                                                                                                                                                                                                   | The number of cache keys associated with this cache. Cache keys are created via the [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). |
| Size                                                                                                                                                                                                                                                   | The current size of the cache in proportion to the limit.                                                                                                                                                                                                          |
| <img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FHMMH3rwoFhQeYUHkeENp%2Ftrash.svg?alt=media&#x26;token=7330c5e8-85ae-4197-850f-3e80b791ce99" alt="" data-size="line"> | Delete the cache (and all associated data).                                                                                                                                                                                                                        |

If you have a lot of caches, you can search by name:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FKH85wECkFelvyTjZ9TE4%2Fcache%20maintenance%20-%20search.png?alt=media&#x26;token=e0131bf1-3a2f-4d2e-a9aa-aa0ba8fa661e" alt=""><figcaption></figcaption></figure>

To access [cache details](#cache-details) for a particular cache, click on its name:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FB3AUGjxMriaWIGev40HV%2Fselect%20cache%20to%20view.png?alt=media&#x26;token=19d78d17-ea2e-43fc-9991-b906c97cf2d6" alt=""><figcaption></figcaption></figure>

## Cache details

When you select a cache from the list, an edit cache page is displayed:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FTQFquyT4cux5h4ch3n7A%2Fcache%20details%201.png?alt=media&#x26;token=f0444f66-582c-4bc8-9c9c-227d37031f13" alt=""><figcaption></figcaption></figure></div>

From here you can:

* [View and change the cache name](#viewing-and-changing-the-cache-name)
* [View and change the maximum age (retention period)](#viewing-and-changing-the-maximum-age-retention-period)
* [View usage information](#viewing-usage-information)
* [View cache contents](#viewing-cache-contents)
* [Clear the cache](#clearing-the-cache)

### Viewing & changing the cache name

To change the name of the cache, simply update the `name` field in the upper `cache detail`**s** panel, then click the `save` button.

When the name is updated and saved, the change is immediately reflected in any [add to cache](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/add-to-cache-shape) shapes in process flows, where this cache is used.

{% hint style="danger" %}
The cache name must not include full stop (**.**) or colon (**:**) characters.
{% endhint %}

### Viewing & changing the maximum age (retention period)

You can use the `maximum age` slider to change the cache retention period for a cache:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FpL1gb8t9rAP9YAIBdvdg%2Fupdate%20cache%20retention.png?alt=media&#x26;token=ec68a0a5-d677-47dd-8bd9-a9c05914f5f1" alt=""><figcaption></figcaption></figure>

Note that:

* The maximum age for a `flow run` cache is 2 hours - this cannot be changed
* The maximum age for a `flow` or `company` cache can be changed to anything up to 7 days

### Viewing usage information

The usage panel shows general usage information about the cache:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F3uwIZtsQEHBZiL7J4nqE%2Fcache%20usage%201.png?alt=media&#x26;token=6522d0ca-ed11-4baf-970d-c1a3cb899e43" alt=""><figcaption></figcaption></figure>

Here you can see:

| Item          | Summary                                                                                                                 |
| ------------- | ----------------------------------------------------------------------------------------------------------------------- |
| Size          | The current size of the cache, shown with a percentage use indicator. The maximum cache size is 50MB                    |
| Created       | The date and time that the cache was created.                                                                           |
| Last accessed | The date and time that the cache was last accessed. This timestamp is updated even when no data was added to the cache. |
| Keys          | The number of keys associated with this cache.                                                                          |

### Viewing cache contents

The `cache contents` panel displays an entry for each cache key update. Information shown varies, depending on the cache type.

#### Flow run cache

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FgSWtXikeYo495RiYUobf%2Fcache%20details%20%20-%20contents%20-%20flow%20run.png?alt=media&#x26;token=ec884077-54ab-4e3c-a13e-c0ba4945e28e" alt=""><figcaption></figcaption></figure>

The following details are displayed for each cache item in a `flow run` type cache:

| Item                                                                                                                                                                                                                                                               | Summary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Flow Run ID                                                                                                                                                                                                                                                        | The unique id of the process flow run that updated the cache key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Started at                                                                                                                                                                                                                                                         | The date and time that the process flow run was started.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| Key                                                                                                                                                                                                                                                                | The cache key name.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| Page                                                                                                                                                                                                                                                               | If multiple pages are added to a cache (for example, if incoming data is paginated or batched via [flow control shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/flow-control-shape)) and the [add to cache](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/add-to-cache-shape/cache-pagination-options#save-all-pages) **save all pages** option is togged ON), each page is listed individually. |
| Unique key                                                                                                                                                                                                                                                         | The internal cache key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| <img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FgarDXZhEoHpllYx9owrc%2Feye-outline%20(1).svg?alt=media&#x26;token=a46da0da-8bbd-4494-8147-df0324393ce1" alt="" data-size="line"> | <p>Click the 'eye' icon to view the content associated with this key. For example:<br><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FDnhhixpgr0LZAB2IA3bh%2Fview%20cache%20key%20content.png?alt=media&#x26;token=cdbb38fb-4c85-4c3d-8d5e-382bc03e23ff" alt=""></p>                                                                                                                                                                                                                  |
| Size                                                                                                                                                                                                                                                               | The size of the cache key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

#### Flow cache / company cache

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F7WFmeXd0BdYpMR0eh5QE%2Fcache%20details%20%20-%20contents%20-%20flow.png?alt=media&#x26;token=628b270e-7f8c-4d01-8170-c64cdc2bd334" alt=""><figcaption></figcaption></figure>

The following details are displayed for each cache item:

| Item                                                                                                                                                                                                                                                               | Summary                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Key                                                                                                                                                                                                                                                                | The cache key name.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Page                                                                                                                                                                                                                                                               | If multiple pages are added to a cache (for example, if incoming data is paginated or batched via [flow control shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/flow-control-shape)) and the [add to cache](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/add-to-cache-shape/cache-pagination-options#save-all-pages) save all pages option is , each page is listed individually. |
| Unique key                                                                                                                                                                                                                                                         | The internal cache key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| <img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FgarDXZhEoHpllYx9owrc%2Feye-outline%20(1).svg?alt=media&#x26;token=a46da0da-8bbd-4494-8147-df0324393ce1" alt="" data-size="line"> | <p>Click the 'eye' icon to view the content associated with this key. For example:<br><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FDnhhixpgr0LZAB2IA3bh%2Fview%20cache%20key%20content.png?alt=media&#x26;token=cdbb38fb-4c85-4c3d-8d5e-382bc03e23ff" alt=""></p>                                                                                                                                                                                                    |
| Size                                                                                                                                                                                                                                                               | The size of the cache key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |

### Clearing the cache

To clear all current content in the cache, click the `clear cacche` button:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F2MkPq3KBiGxXlnSpK5pG%2Fcache%20maintenance%20-%20clear.png?alt=media&#x26;token=3cfe1fb1-8b9c-4a72-b7fd-8ec6e6fdcab1" alt=""><figcaption></figcaption></figure>

This removes any existing data but leaves the cache in place so it can still be [used in process flows](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/cache/add-to-cache-shape).

## Creating a cache

Cache creation is an integral part of [configuring an add to cache shape](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/advanced-shapes/add-to-cache-shape#adding-and-configuring-an-add-to-cache-shape-to-a-process-flow) within your process flow - 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%2FaaNlAYEqbAoi7z1ylm0i%2Fadd%20to%20cache%20shape%20config.png?alt=media&#x26;token=a9eceaa2-f8bc-40c2-9c21-c331577a1821" alt="" width="375"><figcaption></figcaption></figure></div>

However, it can sometimes be useful to create caches via the `data caches` page. To do this, follow the steps below.

{% stepper %}
{% step %}
**Choose to create a new cache**&#x20;

Click the `create cache` button associated with the type of cache you want to create - `flow`, `flow run`, or `company`. For example:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FsPSos4fjBZj5DElHHRmD%2Fcreate%20cache%201.png?alt=media&#x26;token=7cfbf1d0-791d-426c-b9aa-f7c4b435509d" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
For information about the different types of cache that you can create, please see our [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) page.
{% endhint %}
{% endstep %}

{% step %}
**Enter cache details**&#x20;

If you choose to create a `flow` or `flow run` cache, the following details are required:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FkUKgrJBDaSf0oTdO13JH%2Fcreate%20cache%202.png?alt=media&#x26;token=1582f4ae-6812-4ae8-9582-0aa66bfe85cc" alt="" width="563"><figcaption></figcaption></figure></div>

Required fields are summarised below:

<table><thead><tr><th width="223.91796875">Field</th><th>Summary</th></tr></thead><tbody><tr><td>Name</td><td>Enter a name for the cache (this name is displayed wherever the cache is used in the dashboard).</td></tr><tr><td>Flows</td><td><p>Select a process flow to be associated with this cache. </p><p></p><p>All process flows are available for selection, irrespective of whether they include an <a href="add-to-cache-shape">add to cache</a> shape. Selecting a flow here does NOT add/configure <code>add to cache</code> shapes in selected process flows, it simply makes an association. </p><p></p><p>When you go on to add or update an <code>add to cache</code> shape in the associated process flow, this cache will be available for selection (it won't be available in any other process flows). </p></td></tr><tr><td>Data retention</td><td>Select the required duration that cached data should be kept. For more information on this setting, please see our <a href="add-to-cache-shape">Add to cache shape</a> page.</td></tr></tbody></table>

If you choose to create a `company` cache, the following details are required:

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F44F3RvZgJzBhzaGt73nZ%2Fcreate%20cache%203.png?alt=media&#x26;token=dcb1734c-5d90-40bb-a006-06dc3759544c" alt="" width="563"><figcaption></figcaption></figure></div>

This is the same information detailed for `flow` and `flow run` caches above, except there's no requirement to select an associated flow. `company` caches are available for selection in any process flow.&#x20;
{% endstep %}

{% step %}
**Confirm settings**

Click the `save` button to save settings and create the cache.
{% endstep %}
{% endstepper %}
