Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

To Set Up a Caching Strategy for the Cache Scope

You can create a Caching Strategy from a Cache component or from a Global Elements configuration in Anypoint Studio. Once you create a strategy, a Cache component in your flow can reference it.

  1. Open the Caching Strategy configuration window.

    You can open it from the Cache component configuration tab or from the Caching Strategies option in the Global Elements tab within Studio.

  2. Provide a Name for your Caching Strategy.

  3. Reference an ObjectStore or create one for your Cache component to reference.

  4. Select a mechanism for generating a key used for storing events within the Caching Strategy:

    • Default

    • Key Expression: A DataWeave expression (for example, keyGenerationExpression=“#[vars.requestId]).

      Note that for two requests that are the same ("equal"), you need to generate the same key. Otherwise, you can get wrong results.

    • Key Generator: Requires you to implement the com.mulesoft.mule.runtime.cache.api.key.MuleEventKeyGenerator interface.

  5. Perform any optional steps that you need.

    • Select or create a Response Generator.

      Note that this step requires that you implement the com.mulesoft.mule.runtime.cache.api.response.ResponseGenerator interface.

    • Change the Event Copy Strategy from Simple (the default, where data is immutable) to Serializable (where data is mutable).

In this topic: