SlideShare a Scribd company logo
1 of 15
Ankit Lawaniya
9/3/2017 Ankit Lawaniya 1
Caching is all about application performance optimization ,cache can
be very useful in gaining fast application performance .
Cache scope is one of the scope in mule which saves on time and
processing load by storing and reusing frequently called data in the
memory, file system or database which saves processing time and
load if it would have to be access from original source location every
time. We can put any number of message processors into a cache
scope and configure the caching strategy to store the responses (which
contain the payload of the response message) produced by the scope’s
subflow.
Even though mule has its default caching strategy its recommended
to define the global caching strategy because The default caching
strategy uses an InMemoryObject store and should only be used for
testing;
9/3/2017 Ankit Lawaniya 2
When an end user of a flight booking system is looking for the flight
information between Delhi to Kolkata for a particular date, it then
goes through the processing of various steps where it connects to
multiple vendors to collect the flight details. Finally after collecting all
the details the response will be returned to the user. Same processing
steps will be executed for each incoming requests even if multiple
users are looking for the same information. Which means if we receive
100 requests for the same source and destination search for a
particular date, then all of the processing (steps) will be done 100
times.
9/3/2017 Ankit Lawaniya 3
Once the application receives the search request between Delhi to
Kolkata for a particular date the response that has been returned to
the user will be stored in a cache and for all of the next searches for
the same source and destination for that particular date the result can
just be returned from the cache without executing the same steps
repititively.
9/3/2017 Ankit Lawaniya 4
9/3/2017 Ankit Lawaniya 5
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 (i.e. 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.
Each item in the cache is a key/value pair where the key represents
the payload at the cache scope entry point. The value is the result at
the end of the cache scope.By default, Mule uses
SHA256KeyGenerator and a SHA256 digest to generate a key on the
payload. For the cache entry value, Mule will cache not just the
payload at the end of the cache scope, but the whole MuleEvent. The
idea behind all of this is that apart from the payload, you might need
other information such as message properties.
9/3/2017 Ankit Lawaniya 6
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:
1)Processing repeated requests for the same information.
2)Processing requests for information that involve large, non-
consumable message payloads.
9/3/2017 Ankit Lawaniya 7
By default, Mule stores all cached responses in an InMemoryObjectStore.
Below are the multiple ways of creating a caching strategy and define a new
object store if you want to customize the way Mule stores cached responses.
 custom-object-store:Custom object stores are useful when you want to use
a custom persistence mechanism for your ObjectStore's
 In-memory: This store the data inside system memory. The data stored
with In-memory is non-persistent which means in case of application
restart or crash, the data been cached will be lost.
 Managed-store: This stores the data in a place defined by
ListableObjectStore. The data stored with Managed-store is persistent
which means in case of application restart or crash, the data been cached
will no be lost.
 Simple-test-file-store:This stores the data in a file. The data stored with
Simple-test-file-store configuration is persistent which means in case of
application restart or crash, the data been cached will no be lost.
9/3/2017 Ankit Lawaniya 8
9/3/2017 Ankit Lawaniya 9
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:
 invalidate-cache - Completely invalidates a cache. Must reference an
invalidatable caching strategy.
<ee:invalidate-cache cachingStrategy-
ref="InvalidatableCachingStrategy"/>
 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).
<ee:invalidate-key cachingStrategy-
ref="InvalidatableCachingStrategy" keyGenerator-
ref="MD5MuleEventKeyGenerator"/>
9/3/2017 Ankit Lawaniya 10
Let’s walk through how to use Cache scope in mule application.
In this example flow "cachFlow" will be invoked through REST client .
All of the steps including message processor's in the cache scope
will be executed for the first request made for ID= 1 and response will
be returned to the user. The same will be stored in a cache which will
be used to return response hereafter for all of the subsequent requests
made for the same ID without executing the message processor in the
cache scope.
9/3/2017 Ankit Lawaniya 11
9/3/2017 Ankit Lawaniya 12
9/3/2017 Ankit Lawaniya 13
Request URL:
http://localhost:8081/cache/cache?id=1
9/3/2017 Ankit Lawaniya 14
9/3/2017 Ankit Lawaniya 15

More Related Content

Similar to Improving performance with cache scope in mule

Caching for J2ee Enterprise Applications
Caching for J2ee Enterprise ApplicationsCaching for J2ee Enterprise Applications
Caching for J2ee Enterprise Applications
Debajani Mohanty
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With Coherence
James Bayer
 
Introducing windows server_app_fabric
Introducing windows server_app_fabricIntroducing windows server_app_fabric
Introducing windows server_app_fabric
Marco Titta
 
Data power Performance Tuning
Data power Performance TuningData power Performance Tuning
Data power Performance Tuning
KINGSHUK MAJUMDER
 
E24099025李宇洋_專題報告.pdf
E24099025李宇洋_專題報告.pdfE24099025李宇洋_專題報告.pdf
E24099025李宇洋_專題報告.pdf
KerzPAry137
 

Similar to Improving performance with cache scope in mule (20)

Cache scope and strategy
Cache scope and strategy Cache scope and strategy
Cache scope and strategy
 
Caching for J2ee Enterprise Applications
Caching for J2ee Enterprise ApplicationsCaching for J2ee Enterprise Applications
Caching for J2ee Enterprise Applications
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
 
Scalability Considerations
Scalability ConsiderationsScalability Considerations
Scalability Considerations
 
Application and Data Services
Application and Data ServicesApplication and Data Services
Application and Data Services
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With Coherence
 
Application Grid Dev with Coherence
Application Grid Dev with CoherenceApplication Grid Dev with Coherence
Application Grid Dev with Coherence
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With Coherence
 
Introducing windows server_app_fabric
Introducing windows server_app_fabricIntroducing windows server_app_fabric
Introducing windows server_app_fabric
 
Data power Performance Tuning
Data power Performance TuningData power Performance Tuning
Data power Performance Tuning
 
Effective VM Scheduling Strategy for Heterogeneous Cloud Environment
Effective VM Scheduling Strategy for Heterogeneous Cloud EnvironmentEffective VM Scheduling Strategy for Heterogeneous Cloud Environment
Effective VM Scheduling Strategy for Heterogeneous Cloud Environment
 
shashank_micro92_00697015
shashank_micro92_00697015shashank_micro92_00697015
shashank_micro92_00697015
 
Charm a cost efficient multi cloud data hosting scheme with high availability
Charm a cost efficient multi cloud data hosting scheme with high availabilityCharm a cost efficient multi cloud data hosting scheme with high availability
Charm a cost efficient multi cloud data hosting scheme with high availability
 
Noha mega store
Noha mega storeNoha mega store
Noha mega store
 
[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
 
Html5 cache mechanism & local storage
Html5 cache mechanism & local storageHtml5 cache mechanism & local storage
Html5 cache mechanism & local storage
 
E24099025李宇洋_專題報告.pdf
E24099025李宇洋_專題報告.pdfE24099025李宇洋_專題報告.pdf
E24099025李宇洋_專題報告.pdf
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
 
Ieeepro techno solutions 2014 ieee java project - query services in cost ef...
Ieeepro techno solutions   2014 ieee java project - query services in cost ef...Ieeepro techno solutions   2014 ieee java project - query services in cost ef...
Ieeepro techno solutions 2014 ieee java project - query services in cost ef...
 
Ieeepro techno solutions 2014 ieee dotnet project - query services in cost ...
Ieeepro techno solutions   2014 ieee dotnet project - query services in cost ...Ieeepro techno solutions   2014 ieee dotnet project - query services in cost ...
Ieeepro techno solutions 2014 ieee dotnet project - query services in cost ...
 

More from Ankit Lawaniya

More from Ankit Lawaniya (11)

Content based routing using mule choice flow control
Content based routing using mule choice flow controlContent based routing using mule choice flow control
Content based routing using mule choice flow control
 
First successful-router
First successful-routerFirst successful-router
First successful-router
 
Iterative processing using the for each scope in
Iterative processing using the for each scope inIterative processing using the for each scope in
Iterative processing using the for each scope in
 
Cors (cross origin request sharing) in mule
Cors (cross origin request sharing) in muleCors (cross origin request sharing) in mule
Cors (cross origin request sharing) in mule
 
Content enrichment using mule message enricher
Content enrichment using mule message enricherContent enrichment using mule message enricher
Content enrichment using mule message enricher
 
Validation module in mule
Validation module in muleValidation module in mule
Validation module in mule
 
Schema validation filter (xml schema validation)
Schema validation filter (xml schema validation)Schema validation filter (xml schema validation)
Schema validation filter (xml schema validation)
 
Validate json schema component
Validate json schema componentValidate json schema component
Validate json schema component
 
Parse template transformer mule
Parse template transformer muleParse template transformer mule
Parse template transformer mule
 
Active mq read and write flow in mule
Active mq  read and write flow in muleActive mq  read and write flow in mule
Active mq read and write flow in mule
 
Composite source in mule
Composite source in muleComposite source in mule
Composite source in mule
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Improving performance with cache scope in mule

  • 2. Caching is all about application performance optimization ,cache can be very useful in gaining fast application performance . Cache scope is one of the scope in mule which saves on time and processing load by storing and reusing frequently called data in the memory, file system or database which saves processing time and load if it would have to be access from original source location every time. We can put any number of message processors into a cache scope and configure the caching strategy to store the responses (which contain the payload of the response message) produced by the scope’s subflow. Even though mule has its default caching strategy its recommended to define the global caching strategy because The default caching strategy uses an InMemoryObject store and should only be used for testing; 9/3/2017 Ankit Lawaniya 2
  • 3. When an end user of a flight booking system is looking for the flight information between Delhi to Kolkata for a particular date, it then goes through the processing of various steps where it connects to multiple vendors to collect the flight details. Finally after collecting all the details the response will be returned to the user. Same processing steps will be executed for each incoming requests even if multiple users are looking for the same information. Which means if we receive 100 requests for the same source and destination search for a particular date, then all of the processing (steps) will be done 100 times. 9/3/2017 Ankit Lawaniya 3
  • 4. Once the application receives the search request between Delhi to Kolkata for a particular date the response that has been returned to the user will be stored in a cache and for all of the next searches for the same source and destination for that particular date the result can just be returned from the cache without executing the same steps repititively. 9/3/2017 Ankit Lawaniya 4
  • 6. 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 (i.e. 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. Each item in the cache is a key/value pair where the key represents the payload at the cache scope entry point. The value is the result at the end of the cache scope.By default, Mule uses SHA256KeyGenerator and a SHA256 digest to generate a key on the payload. For the cache entry value, Mule will cache not just the payload at the end of the cache scope, but the whole MuleEvent. The idea behind all of this is that apart from the payload, you might need other information such as message properties. 9/3/2017 Ankit Lawaniya 6
  • 7. 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: 1)Processing repeated requests for the same information. 2)Processing requests for information that involve large, non- consumable message payloads. 9/3/2017 Ankit Lawaniya 7
  • 8. By default, Mule stores all cached responses in an InMemoryObjectStore. Below are the multiple ways of creating a caching strategy and define a new object store if you want to customize the way Mule stores cached responses.  custom-object-store:Custom object stores are useful when you want to use a custom persistence mechanism for your ObjectStore's  In-memory: This store the data inside system memory. The data stored with In-memory is non-persistent which means in case of application restart or crash, the data been cached will be lost.  Managed-store: This stores the data in a place defined by ListableObjectStore. The data stored with Managed-store is persistent which means in case of application restart or crash, the data been cached will no be lost.  Simple-test-file-store:This stores the data in a file. The data stored with Simple-test-file-store configuration is persistent which means in case of application restart or crash, the data been cached will no be lost. 9/3/2017 Ankit Lawaniya 8
  • 10. 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:  invalidate-cache - Completely invalidates a cache. Must reference an invalidatable caching strategy. <ee:invalidate-cache cachingStrategy- ref="InvalidatableCachingStrategy"/>  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). <ee:invalidate-key cachingStrategy- ref="InvalidatableCachingStrategy" keyGenerator- ref="MD5MuleEventKeyGenerator"/> 9/3/2017 Ankit Lawaniya 10
  • 11. Let’s walk through how to use Cache scope in mule application. In this example flow "cachFlow" will be invoked through REST client . All of the steps including message processor's in the cache scope will be executed for the first request made for ID= 1 and response will be returned to the user. The same will be stored in a cache which will be used to return response hereafter for all of the subsequent requests made for the same ID without executing the message processor in the cache scope. 9/3/2017 Ankit Lawaniya 11