---
schema_version: "1"
id: ee6b26b346e9a106ec565e0041a5a73d770d0e064b2a94928b3b86db3f802d1b
title: Enhance Performance Using Cache Blocks (Managed Package)
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_enhance_performance_using_cache_blocks.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_enhance_performance_using_cache_blocks.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 4bb94ba7ef6a96882f03d07b4ee82183abc8a845e9f2307ded802e7e27d6b9fe
description: For the managed package runtime, using a cache to store frequently accessed, infrequently updated data saves round trips to the database and improves performance. Use Cache Blocks if some parts of the Integration Procedure update data, or if you need different cached data to expire at different times. For example, current weather data changes more frequently than user session data.
products:
  - Omnistudio
release: "264"
---
# Enhance Performance Using Cache Blocks (Managed Package)

For the managed package runtime, using a cache to store frequently accessed, infrequently updated data saves round trips to the database and improves performance. Use Cache Blocks if some parts of the Integration Procedure update data, or if you need different cached data to expire at different times. For example, current weather data changes more frequently than user session data.

![Managed Package app icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/resources-global/_corporate/images/managedpackageicon.png) This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see [Omnistudio Help](https://help.salesforce.com/s/articleView?id=xcloud.os_omnistudio_standard.htm&language=en_US).

Cache Blocks are available in Summer '19 and later releases.

It's important to allocate space in the VlocityAPIResponse cache partition and to understand how top-level Integration Procedure caching interacts with Cache Blocks. See [Cache for Omnistudio Data Mappers (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_cache_for_dataraptors_and_integration_procedures.htm&release=264.0.0&type=5 "For the managed package runtime, Omnistudio offers multiple caching options to improve performance and minimize unnecessary data processing in Data Mappers. The two primary user-configurable caching types are Org Cache and Session Cache, which are available in the Data Mapper designer. These caching mechanisms are part of the Salesforce Platform Cache and are implemented through Vlocity Cache in Omnistudio with managed package runtime. Each serves a distinct purpose and comes with specific configuration considerations.").

A Cache Block saves the output of the steps within it to a session or org cache in the VlocityAPIResponse cache partition for quick retrieval.

Here’s an example Cache Block configuration:

![The Element Name is CacheBlock1. The Salesforce Platform Cache Type is Org Cache. Time to Live in Minutes is set to 5. Under Cache Keys, contactId is set to %ExtractContact:Contact:Id% and contactName is set to %ExtractContact:Contact:Name%.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/omnistudio_for_managed_packages/images/cacheblockexampleconfig.png)

## Test Options for Cache-Block Caching in Preview

When you test an Integration Procedure that includes a Cache Block in the Preview tab, you can use two caching settings in the Options JSON section. These settings also affect top-level caching but have no effect on the metadata cache.

- `ignoreCache` — Doesn't clear or save data to the cache. The default value is `true`. Use this setting to test Integration Procedure steps without the possible interference of caching effects.
- `resetCache` — Forces data to be saved to the cache. The default value is `false`. Use this setting as part of testing caching itself.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/images/icon_note.png)

Note

To test caching, be sure to set `ignoreCache` to `false`. See [Create a Cache Block Example (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_create_a_cache_block_example.htm&release=264.0.0&type=5 "For the managed package runtime, an Integration Procedure accepts a list of first or last names and retrieves Contacts having those names. A Cache Block improves Contact retrieval performance.").

The Options pane on the Preview tab looks like this:

![Under Errors/Debug Output are the Debug Log, errors, and Options panes. The Options pane is expanded to reveal resetCache, ignoreCache, and other options.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/omnistudio_for_managed_packages/images/cachingpreviewoptions.png)

You can pass ignoreCache and resetCache as parameters when you invoke an Integration Procedure that uses caching using a REST API. For example, you can include `?resetCache=true` in the URL to force caching. See [Integration Procedure Invocation Using POST (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_integration_procedure_invocation_using_post.htm&release=264.0.0&type=5 "For the managed package runtime, to send JSON data to an Integration Procedure, issue a POST call. With a POST call, you can specify inline values in the URL path, append query parameters to the URL, and include a JSON request body.").

## Cache Block JSON Nodes

An active Integration Procedure that uses a Cache Block can include the following JSON nodes in its Debug Log output, which is visible on the Preview tab:

- `vlcCacheKey` — Key for any data stored in the cache
- `vlcCacheResult` — Included and set to true if data is retrieved from the cache
- `vlcCacheEnabled` — Included and set to false if the `ignoreCache` setting disables caching
- `vlcCacheException` — Any caching errors

These nodes are under the `Info` node for the Cache Block. For example, if the Cache Block is named CacheBlock1, these nodes are under the `CacheBlock1Info` node. For example:

![Under Errors/Debug Output, the Debug Log pane is expanded. JSON data for CacheBlock1 is displayed, including vlcCacheResult and vlcCacheKey.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/omnistudio_for_managed_packages/images/cachekeyresponse.png)

## Apex Methods to Clear Cache Block Data

Cache-clearing methods are available in Winter '20 and later releases. If you must clear Cache Block data from the cache, follow the instructions in [this topic](https://help.salesforce.com/s/articleView?id=xcloud.os_fix_the_datapack_import_export_error_no_configuration_found.htm&release=264.0.0&type=5 "For the managed package runtime, if you see the error message No Configuration Found while trying to import or export a DataPack, the issue is most likely with the configuration of the Salesforce org. This error often occurs in developer sandboxes that are missing some of the configuration files owing to a recent refresh or an install or upgrade that has missed a post-install or post-upgrade step. You can fix this error with code in Anonymous Apex."), but execute one of these lines of code instead:

```
IntegrationProcedureService.clearSessionCache('Type_Subtype', 'blockName', new Map<String, Object>{'key' => 'value'});

IntegrationProcedureService.clearOrgCache('Type_Subtype', 'blockName', new Map<String, Object>{'key' => 'value'});

IntegrationProcedureService.clearSessionCache('vlcCacheKey');

IntegrationProcedureService.clearOrgCache('vlcCacheKey');
```

You can clear all cached data for an Integration Procedure, including session cache data, org cache data, and metadata. Follow the instructions in [this topic](https://help.salesforce.com/s/articleView?id=xcloud.os_fix_the_datapack_import_export_error_no_configuration_found.htm&release=264.0.0&type=5 "For the managed package runtime, if you see the error message No Configuration Found while trying to import or export a DataPack, the issue is most likely with the configuration of the Salesforce org. This error often occurs in developer sandboxes that are missing some of the configuration files owing to a recent refresh or an install or upgrade that has missed a post-install or post-upgrade step. You can fix this error with code in Anonymous Apex."), but execute this line of code instead, specifying the Integration Procedure's Type and Subtype:

`IntegrationProcedureService.clearAllCache('Type_Subtype');`

For example, execute the following code if:

- You want to clear a Cache Block key in the Org Cache
- The Type\_Subtype parameter for the Integration Procedure is LastNames\_Cached
- The Cache Block is named CacheContacts
- The cache key you want to clear is ContactLastName
- The key's value is Smith

```
IntegrationProcedureService.clearOrgCache('LastNames_Cached', 'CacheContacts', new Map<String, Object>{'ContactLastName' => 'Smith'});
```

The following example clears the session cache using a vlcCacheKey value:

`IntegrationProcedureService.clearSessionCache('2032076016a1745801061oc');`

- **[Cache Block Properties (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_cache_block_properties.htm&release=264.0.0&type=5)**  
    For the managed package runtime, these properties are unique to or function in a unique manner in Cache Blocks. Use Cache Blocks if some parts of the Integration Procedure update data and therefore shouldn't be cached, or if different cached data should expire at different times.
- **[Create a Cache Block Example (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_create_a_cache_block_example.htm&release=264.0.0&type=5)**  
    For the managed package runtime, an Integration Procedure accepts a list of first or last names and retrieves Contacts having those names. A Cache Block improves Contact retrieval performance.