SlideShare a Scribd company logo
1 of 10
Cache scope and strategy
By,
Harish
Cache Scope
● The Cache Scope is a Mule feature for storing and reusing frequently called data.
The Cache Scope saves on time and processing load.
Overview:
● You can place any no of message processors into a cache scope and configure the
caching strategy to store the responses.
● Mule’s default caching strategy defines how data are stored and reused.
● But if you want to adjust cache behavior, you can customize a global caching
strategy in Mule and make it available for use by all cache scopes in your
application.
Behavior:
● Mule sends a message into the cache scope and the parent flow expects an output.
● The cache scope processes the message, delivers the output to the parent flow and
saves the output (that is, caches the response).
● The next time Mule sends the same kind of message into the cache scope, the cache
scope may offer a cached response rather than invoking, again, a potentially
time-consuming process.
Usage:
● You can use a cache scope to reduce the processing load on the Mule instance and
speed up message processing within a flow. It is particularly effective for:
-->Processing repeated requests for the same information.
-->Processing requests for information that involve large, non-consumable message
payloads.
Caching Strategy
● The caching strategy defines the actions a cache scope takes when a message enters
its sub flow.
-->If there is no cached response event (a cache “miss”), cache scope processes the
message.
-->If there is a cached response event (a cache “hit”), cache scope offers the cached
response event rather than processing the message.
● You can customize a global caching strategy in Mule for the cache scopes in your
application to follow, or you can use Mule’s default caching strategy.
Default Caching Strategy:
● A message enters the cache scope.
● Cache scope determines whether the message’s payload is consumable. A
consumable payload can only be read once before it is lost – such as a streaming
payload – and cannot be cached.
-->If the message payload is consumable, cache scope always processes the message;
nothing is cached and the caching strategy is abandoned.
-->If the message payload is not consumable, cache scope continues to the next step
in the caching strategy.
● Cache scope generates a key to identify the message’s payload. Mule uses an
SHA256KeyGenerator and a SHA256 digest to generate a unique key for the
message payload.
● Cache scope compares the newly-generated key to cached responses that it has
previously processed and saved in an InMemoryObjectStore — a container for
cached data. In other words, cache scope searches for a “cache hit” it can offer
instead of processing the message.
-->Where there is a cache miss, cache scope processes the new message and
produces a response. Cache scope also saves the resulting response in the object
store. (If the response has a consumable payload, it does not cache the response.)
-->Where there is a cache hit, the caching strategy uses a DefaultResponseGenerator
to generate a response that combines data from both the new request and the cached
response. (If the generated response has a consumable payload, it does not cache the
response.)
● Cache scope pushes the response out into the parent flow for continued processing
Field Descriptions
● Display Name field - Value is Cache - Customize to display a unique name for the
scope in your application.
● Caching strategy reference
● Use Default caching strategy (Default) - Select if you want the cache scope to follow
Mule’s Default Caching Strategy.
● Reference to a strategy - Select to configure the cache scope to follow a global
caching strategy that you have created; select the global caching strategy from the
drop-down menu or create one by clicking the green plus sign.
● Filter field:
● Process all messages (Default) - Select if you want the cache scope to execute the
caching strategy for all messages that enter the scope.
● Filter messages using an expression - Select if you want the cache scope to execute
the caching strategy ONLY for messages that match the expression(s) defined in this
field.
● 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; Mule never saves nor offers cached
responses.
● Filter messages using a global filter - Select if you want the cache scope to execute
the caching strategy only for messages that successfully pass through the designated
global filter.
● If the message passes through filter, Mule executes the caching strategy.
● If the message fails to pass through filter, Mule processes the message through all
message processors within the cache scope; Mule never saves nor offers cached
responses.
Configuring an Object Store for Cache
● By default, Mule stores all cached responses in an InMemoryObjectStore. Create a
Caching Strategy and define a new object store if you want to customize the way
Mule stores cached responses.
Field Descriptions:
● name (for in-memory, simple-text) --- Enter a unique name for your object store.
● storeName (for managed)
● persistent="true" --- Check to ensure that the object store saves cached responses in
persistent storage. Default is false.
● MaxEntries --- Enter an integer to limit the number of cached responses the object
store saves
● EntryTTL ---(Time To Live) Enter an integer to indicate the number of milliseconds
that a cached response has to live in the object store before it is expunged.
● Expiration Interval --- Enter an integer to indicate, in milliseconds, the frequency
with which the object store checks for cached response events it should expunge.
● Directory --- Enter the file path of the file where object store saves cached responses
● NOTE: To enable synchronization, use the synchronized property in the caching
strategy element. Accepted values are true and false.
Invalidating a Cache:
● Removing the cache property that is already applied.
● Mule provides the InvalidatableCachingStrategy interface, which allows you to
invalidate a complete cache or a cache key without the need for custom code or
configuration
● There are two message processors for invalidating caches:
1)invalidate-cache - Completely invalidates a cache. Must reference an invalidatable
caching strategy.
EXAMPLE:
<ee:invalidate-cache cachingStrategy-ref="InvalidatableCachingStrategy"/>
● 2) invalidate-key - Calculates a cache key from the current event, then searches for it
in the cache and removes it if present. Must reference an invalidatable caching
strategy and, optionally, a MuleEventKeyGenerator. If no MuleEventKeyGenerator
is provided, Mule uses the default implementation
(SHA256MuleEventKeyGenerator).
EXAMPLE:
<ee:invalidate-key cachingStrategy-ref="InvalidatableCachingStrategy"
keyGenerator-ref="MD5MuleEventKeyGenerator"/>

More Related Content

Similar to Cache scope and strategy

[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching SolutionsITviec
 
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...Jitendra Bafna
 
TGI Pulsar - episode 016: backlog vs storage size
TGI Pulsar - episode 016: backlog vs storage sizeTGI Pulsar - episode 016: backlog vs storage size
TGI Pulsar - episode 016: backlog vs storage sizeStreamNative
 
Memory management in oracle
Memory management in oracleMemory management in oracle
Memory management in oracleDavin Abraham
 
1st Feb 2020 MuleSoft Meetup
1st Feb 2020 MuleSoft Meetup1st Feb 2020 MuleSoft Meetup
1st Feb 2020 MuleSoft MeetupPankaj Goyal
 
UiPath Development Best Practices.pptx
UiPath Development Best Practices.pptxUiPath Development Best Practices.pptx
UiPath Development Best Practices.pptxApurbaSamanta9
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksYoung Alista
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksTony Nguyen
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksFraboni Ec
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksLuis Goldster
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksHoang Nguyen
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksHarry Potter
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching worksJames Wong
 

Similar to Cache scope and strategy (20)

How to use Cache scope
How to use Cache scopeHow to use Cache scope
How to use Cache scope
 
[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions
 
Cache scope
Cache scopeCache scope
Cache scope
 
Mule CacheScope
Mule CacheScopeMule CacheScope
Mule CacheScope
 
Cache scope
Cache scopeCache scope
Cache scope
 
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
MuleSoft Surat Virtual Meetup#26 - Implementing Hybrid MuleSoft Runtime - Any...
 
TGI Pulsar - episode 016: backlog vs storage size
TGI Pulsar - episode 016: backlog vs storage sizeTGI Pulsar - episode 016: backlog vs storage size
TGI Pulsar - episode 016: backlog vs storage size
 
C3 w3
C3 w3C3 w3
C3 w3
 
Redis
RedisRedis
Redis
 
Memory management in oracle
Memory management in oracleMemory management in oracle
Memory management in oracle
 
Caching in drupal
Caching in drupalCaching in drupal
Caching in drupal
 
1st Feb 2020 MuleSoft Meetup
1st Feb 2020 MuleSoft Meetup1st Feb 2020 MuleSoft Meetup
1st Feb 2020 MuleSoft Meetup
 
UiPath Development Best Practices.pptx
UiPath Development Best Practices.pptxUiPath Development Best Practices.pptx
UiPath Development Best Practices.pptx
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
 

More from Harish43

Rest service in mule
Rest service in mule Rest service in mule
Rest service in mule Harish43
 
Mule management console installation steps
Mule management console installation stepsMule management console installation steps
Mule management console installation stepsHarish43
 
Java components in mule
Java components in muleJava components in mule
Java components in muleHarish43
 
Queues and Mule Transport Mechanisms
Queues and Mule Transport MechanismsQueues and Mule Transport Mechanisms
Queues and Mule Transport MechanismsHarish43
 
Clustering concepts
Clustering conceptsClustering concepts
Clustering conceptsHarish43
 
Batch processing
Batch processingBatch processing
Batch processingHarish43
 
Batch processing
Batch processingBatch processing
Batch processingHarish43
 

More from Harish43 (7)

Rest service in mule
Rest service in mule Rest service in mule
Rest service in mule
 
Mule management console installation steps
Mule management console installation stepsMule management console installation steps
Mule management console installation steps
 
Java components in mule
Java components in muleJava components in mule
Java components in mule
 
Queues and Mule Transport Mechanisms
Queues and Mule Transport MechanismsQueues and Mule Transport Mechanisms
Queues and Mule Transport Mechanisms
 
Clustering concepts
Clustering conceptsClustering concepts
Clustering concepts
 
Batch processing
Batch processingBatch processing
Batch processing
 
Batch processing
Batch processingBatch processing
Batch processing
 

Recently uploaded

Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 

Recently uploaded (20)

Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 

Cache scope and strategy

  • 1. Cache scope and strategy By, Harish
  • 2. Cache Scope ● The Cache Scope is a Mule feature for storing and reusing frequently called data. The Cache Scope saves on time and processing load. Overview: ● You can place any no of message processors into a cache scope and configure the caching strategy to store the responses. ● Mule’s default caching strategy defines how data are stored and reused. ● But if you want to adjust cache behavior, you can customize a global caching strategy in Mule and make it available for use by all cache scopes in your application.
  • 3. Behavior: ● Mule sends a message into the cache scope and the parent flow expects an output. ● The cache scope processes the message, delivers the output to the parent flow and saves the output (that is, caches the response). ● The next time Mule sends the same kind of message into the cache scope, the cache scope may offer a cached response rather than invoking, again, a potentially time-consuming process. Usage: ● You can use a cache scope to reduce the processing load on the Mule instance and speed up message processing within a flow. It is particularly effective for: -->Processing repeated requests for the same information. -->Processing requests for information that involve large, non-consumable message payloads.
  • 4. Caching Strategy ● The caching strategy defines the actions a cache scope takes when a message enters its sub flow. -->If there is no cached response event (a cache “miss”), cache scope processes the message. -->If there is a cached response event (a cache “hit”), cache scope offers the cached response event rather than processing the message. ● You can customize a global caching strategy in Mule for the cache scopes in your application to follow, or you can use Mule’s default caching strategy. Default Caching Strategy: ● A message enters the cache scope. ● Cache scope determines whether the message’s payload is consumable. A consumable payload can only be read once before it is lost – such as a streaming payload – and cannot be cached. -->If the message payload is consumable, cache scope always processes the message; nothing is cached and the caching strategy is abandoned. -->If the message payload is not consumable, cache scope continues to the next step in the caching strategy.
  • 5. ● Cache scope generates a key to identify the message’s payload. Mule uses an SHA256KeyGenerator and a SHA256 digest to generate a unique key for the message payload. ● Cache scope compares the newly-generated key to cached responses that it has previously processed and saved in an InMemoryObjectStore — a container for cached data. In other words, cache scope searches for a “cache hit” it can offer instead of processing the message. -->Where there is a cache miss, cache scope processes the new message and produces a response. Cache scope also saves the resulting response in the object store. (If the response has a consumable payload, it does not cache the response.) -->Where there is a cache hit, the caching strategy uses a DefaultResponseGenerator to generate a response that combines data from both the new request and the cached response. (If the generated response has a consumable payload, it does not cache the response.) ● Cache scope pushes the response out into the parent flow for continued processing
  • 6. Field Descriptions ● Display Name field - Value is Cache - Customize to display a unique name for the scope in your application. ● Caching strategy reference ● Use Default caching strategy (Default) - Select if you want the cache scope to follow Mule’s Default Caching Strategy. ● Reference to a strategy - Select to configure the cache scope to follow a global caching strategy that you have created; select the global caching strategy from the drop-down menu or create one by clicking the green plus sign. ● Filter field: ● Process all messages (Default) - Select if you want the cache scope to execute the caching strategy for all messages that enter the scope. ● Filter messages using an expression - Select if you want the cache scope to execute the caching strategy ONLY for messages that match the expression(s) defined in this field. ● If the message matches the expression(s), Mule executes the caching strategy.
  • 7. ● If the message does not match expression(s), Mule processes the message through all message processors within the cache scope; Mule never saves nor offers cached responses. ● Filter messages using a global filter - Select if you want the cache scope to execute the caching strategy only for messages that successfully pass through the designated global filter. ● If the message passes through filter, Mule executes the caching strategy. ● If the message fails to pass through filter, Mule processes the message through all message processors within the cache scope; Mule never saves nor offers cached responses.
  • 8. Configuring an Object Store for Cache ● By default, Mule stores all cached responses in an InMemoryObjectStore. Create a Caching Strategy and define a new object store if you want to customize the way Mule stores cached responses. Field Descriptions: ● name (for in-memory, simple-text) --- Enter a unique name for your object store. ● storeName (for managed) ● persistent="true" --- Check to ensure that the object store saves cached responses in persistent storage. Default is false. ● MaxEntries --- Enter an integer to limit the number of cached responses the object store saves ● EntryTTL ---(Time To Live) Enter an integer to indicate the number of milliseconds that a cached response has to live in the object store before it is expunged. ● Expiration Interval --- Enter an integer to indicate, in milliseconds, the frequency with which the object store checks for cached response events it should expunge.
  • 9. ● Directory --- Enter the file path of the file where object store saves cached responses ● NOTE: To enable synchronization, use the synchronized property in the caching strategy element. Accepted values are true and false. Invalidating a Cache: ● Removing the cache property that is already applied. ● Mule provides the InvalidatableCachingStrategy interface, which allows you to invalidate a complete cache or a cache key without the need for custom code or configuration ● There are two message processors for invalidating caches: 1)invalidate-cache - Completely invalidates a cache. Must reference an invalidatable caching strategy. EXAMPLE: <ee:invalidate-cache cachingStrategy-ref="InvalidatableCachingStrategy"/>
  • 10. ● 2) invalidate-key - Calculates a cache key from the current event, then searches for it in the cache and removes it if present. Must reference an invalidatable caching strategy and, optionally, a MuleEventKeyGenerator. If no MuleEventKeyGenerator is provided, Mule uses the default implementation (SHA256MuleEventKeyGenerator). EXAMPLE: <ee:invalidate-key cachingStrategy-ref="InvalidatableCachingStrategy" keyGenerator-ref="MD5MuleEventKeyGenerator"/>