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.
-
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.
-
Provide a Name for your Caching Strategy.
-
Reference an ObjectStore or create one for your Cache component to reference.
-
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.
-
-
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).
-