Contact Us 1-800-596-4880

Configure the Cache Scope

  1. In your Mule app, add a Cache scope to a flow.

  2. Click to open the General tab for the Cache scope.

  3. Configure the Cache scope:

    • Provide a Display Name.

    • Select a Caching Strategy.


      • From the UI: My_Caching_Strategy

      • In the Studio XML: cachingStrategy-ref="My_Caching_Strategy"

        MuleSoft recommends that you reference a Caching Strategy that uses an ObjectStore instead of using the default in a production environment.

        If you need to create a Caching Strategy, see the procedure in See Also.

  4. Opt to set up a filter for specific payloads if you need one.

    Example that uses a DataWeave expression: filterExpression="#[user.isPremium()]"

    If the message matches the expression(s), Mule executes the Caching Strategy.

    If the message does not match expression(s), Mule processes the message through all message processors within the Cache scope but never saves or produces cached responses.

Example Cache Scope Configuration

The following example shows the configuration of a Caching Strategy, which is then referenced by a Cache Scope that contains a Database Select operation and a Transform component:

<!-- Caching Strategy definition-->
<ee:object-store-caching-strategy name="Caching_Strategy" doc:name="Caching Strategy" />

<!-- The Database Connector config is necessary in this example because there is a Database Select operation-->
<db:config name="Database_Config" doc:name="Database Config" >
    <!-- Database Connector Configuration -->

<!-- Cache Scope configuration referencing the Caching Strategy-->
<ee:cache doc:name="Cache" cachingStrategy-ref="Caching_Strategy">
  <db:select doc:name="Select" config-ref="Database_Config">
    <db:sql >
      <!-- An SQL query-->
  <ee:transform doc:name="Transform Message" >
    <ee:message >
      <ee:set-payload >
        <!-- A DataWeave transformation for the query results -->