Create a Cache Block Example

In this example, an Integration Procedure accepts a list of first or last names and retrieves Contacts having those names. A Cache Block improves Contact retrieval performance.

In this example, the Integration Procedure has these components:

  • A Cache Block, named CacheBlock1

  • A Loop Block within the Cache Block, named LoopBlock1

  • An Omnistudio Data Mapper Extract Action within the Loop Block, named ExtractContact

  • A Response Action, named ResponseAction

To build this Integration Procedure:

  1. Create an Integration Procedure.
  2. Add a Cache Block component:
    • To open the Elements panel, click +, select Cache Block, click Three dots, and select Details.
    • If you’re using the designer on a managed package, open the Available Components panel, and drag Cache Block to the Structure panel.
  3. Configure the Cache Block component with these settings:

    Property

    Value

    Salesforce Platform Cache Type

    Org Cache

    Time To Live In Minutes

    5

    Cache Keys

    • Key: contactId
    • Value: %ExtractContact:Contact:Id%
    • Key: contactName
    • Value: %ExtractContact:Contact:Name%

    Cache Block Output

    • Key: LoopBlock1
    • Value: %LoopBlock1%
  4. Add a Loop Block inside the Cache Block and configure it with these settings:

    Property

    Value

    Loop List

    names

    Additional Loop Output

    • Key: ExtractContact
    • Value: %ExtractContact%
  5. Create a Data Mapper Extract that the Data Mapper Extract Action calls, and configure it with these settings:

    Tab

    Settings

    Extract

    A Contact extract step set to Contact Name LIKE name

    Output

    A mapping from Contact:Id to Contact:Id

    A mapping from Contact:Name to Contact:Name

    To create a Data Mapper Extract, see the examples in Omnistudio Data Mapper Extract Examples.

  6. Add a Data Mapper Extract Action inside the Loop Block, and configure it with these settings:

    Property

    Value

    Element Name

    ExtractContact

    Data Mapper Interface

    ExtractContactName

    Data Source

    names:name

    Filter Value

    name

  7. Add a Response Action below the Loop Block, and configure it with these settings:

    Property

    Value

    Send JSON Path

    CacheBlock1

  8. Click Edit as JSON. If you’re using the designer on a managed package, click Preview, and then click Edit as JSON.
  9. Copy this JSON data and paste it into the Input Parameters panel:
    {
        "names": [
            {
                "name": "Miller"
            },
            {
                "name": "Torres"
            }
        ]
    }

    To demonstrate performance most effectively, specify common and/or many names.

  10. Click Execute and note the resulting Browser, Server, and Apex CPU values.
  11. Open the Options pane and change the ignoreCache value to false.
  12. Click Execute. This step populates the cache, so the resulting Browser, Server, and Apex CPU values should be similar to the previous values.
  13. Click Execute. This step uses the cached values, so the resulting Browser, Server, and Apex CPU values should be noticeably less than the previous values.
  14. To see the vlcCacheKey and vlcCacheResult nodes, open the Debug Log and scroll to the CacheBlock1Info node.