SlideShare a Scribd company logo
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
Ad

More Related Content

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
Harish43
 
Caching for J2ee Enterprise Applications
Caching for J2ee Enterprise ApplicationsCaching for J2ee Enterprise Applications
Caching for J2ee Enterprise Applications
Debajani Mohanty
 
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)
IJERD Editor
 
Scalability Considerations
Scalability ConsiderationsScalability Considerations
Scalability Considerations
Navid Malek
 
Application and Data Services
Application and Data ServicesApplication and Data Services
Application and Data Services
Big Data Value Association
 
Application Grid Dev with Coherence
Application Grid Dev with CoherenceApplication Grid Dev with Coherence
Application Grid Dev with Coherence
James Bayer
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With Coherence
James Bayer
 
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
 
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
International Journal of Science and Research (IJSR)
 
shashank_micro92_00697015
shashank_micro92_00697015shashank_micro92_00697015
shashank_micro92_00697015
Shashank Nemawarkar
 
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
Pvrtechnologies Nellore
 
Noha mega store
Noha mega storeNoha mega store
Noha mega store
Noha Elprince
 
[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
ITviec
 
Html5 cache mechanism & local storage
Html5 cache mechanism & local storageHtml5 cache mechanism & local storage
Html5 cache mechanism & local storage
Sendhil Kumar Kannan
 
Opetating System Memory management
Opetating System Memory managementOpetating System Memory management
Opetating System Memory management
Johan Granados Montero
 
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...
hemanthbbc
 
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 ...
ASAITHAMBIRAJAA
 
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
 
Cache scope and strategy
Cache scope and strategy Cache scope and strategy
Cache scope and strategy
Harish43
 
Caching for J2ee Enterprise Applications
Caching for J2ee Enterprise ApplicationsCaching for J2ee Enterprise Applications
Caching for J2ee Enterprise Applications
Debajani Mohanty
 
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)
IJERD Editor
 
Scalability Considerations
Scalability ConsiderationsScalability Considerations
Scalability Considerations
Navid Malek
 
Application Grid Dev with Coherence
Application Grid Dev with CoherenceApplication Grid Dev with Coherence
Application Grid Dev with Coherence
James Bayer
 
App Grid Dev With Coherence
App Grid Dev With CoherenceApp Grid Dev With Coherence
App Grid Dev With Coherence
James Bayer
 
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
 
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
Pvrtechnologies Nellore
 
[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
ITviec
 
Html5 cache mechanism & local storage
Html5 cache mechanism & local storageHtml5 cache mechanism & local storage
Html5 cache mechanism & local storage
Sendhil Kumar Kannan
 
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...
hemanthbbc
 
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 ...
ASAITHAMBIRAJAA
 
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
 

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
Ankit Lawaniya
 
First successful-router
First successful-routerFirst successful-router
First successful-router
Ankit Lawaniya
 
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
Ankit Lawaniya
 
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
Ankit Lawaniya
 
Content enrichment using mule message enricher
Content enrichment using mule message enricherContent enrichment using mule message enricher
Content enrichment using mule message enricher
Ankit Lawaniya
 
Validation module in mule
Validation module in muleValidation module in mule
Validation module in mule
Ankit Lawaniya
 
Schema validation filter (xml schema validation)
Schema validation filter (xml schema validation)Schema validation filter (xml schema validation)
Schema validation filter (xml schema validation)
Ankit Lawaniya
 
Validate json schema component
Validate json schema componentValidate json schema component
Validate json schema component
Ankit Lawaniya
 
Parse template transformer mule
Parse template transformer muleParse template transformer mule
Parse template transformer mule
Ankit Lawaniya
 
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
Ankit Lawaniya
 
Composite source in mule
Composite source in muleComposite source in mule
Composite source in mule
Ankit Lawaniya
 
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
Ankit Lawaniya
 
First successful-router
First successful-routerFirst successful-router
First successful-router
Ankit Lawaniya
 
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
Ankit Lawaniya
 
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
Ankit Lawaniya
 
Content enrichment using mule message enricher
Content enrichment using mule message enricherContent enrichment using mule message enricher
Content enrichment using mule message enricher
Ankit Lawaniya
 
Validation module in mule
Validation module in muleValidation module in mule
Validation module in mule
Ankit Lawaniya
 
Schema validation filter (xml schema validation)
Schema validation filter (xml schema validation)Schema validation filter (xml schema validation)
Schema validation filter (xml schema validation)
Ankit Lawaniya
 
Validate json schema component
Validate json schema componentValidate json schema component
Validate json schema component
Ankit Lawaniya
 
Parse template transformer mule
Parse template transformer muleParse template transformer mule
Parse template transformer mule
Ankit Lawaniya
 
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
Ankit Lawaniya
 
Composite source in mule
Composite source in muleComposite source in mule
Composite source in mule
Ankit Lawaniya
 
Ad

Recently uploaded (20)

MINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PRMINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PR
MIND CTI
 
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and MLGyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
Gyrus AI
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
The Microsoft Excel Parts Presentation.pdf
The Microsoft Excel Parts Presentation.pdfThe Microsoft Excel Parts Presentation.pdf
The Microsoft Excel Parts Presentation.pdf
YvonneRoseEranista
 
UiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer OpportunitiesUiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer Opportunities
DianaGray10
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
TrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI PaymentsTrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI Payments
Trs Labs
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Play It Safe: Manage Security Risks - Google Certificate
Play It Safe: Manage Security Risks - Google CertificatePlay It Safe: Manage Security Risks - Google Certificate
Play It Safe: Manage Security Risks - Google Certificate
VICTOR MAESTRE RAMIREZ
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
Financial Services Technology Summit 2025
Financial Services Technology Summit 2025Financial Services Technology Summit 2025
Financial Services Technology Summit 2025
Ray Bugg
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
Connect and Protect: Networks and Network Security
Connect and Protect: Networks and Network SecurityConnect and Protect: Networks and Network Security
Connect and Protect: Networks and Network Security
VICTOR MAESTRE RAMIREZ
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
MINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PRMINDCTI revenue release Quarter 1 2025 PR
MINDCTI revenue release Quarter 1 2025 PR
MIND CTI
 
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and MLGyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
Gyrus AI
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
The Microsoft Excel Parts Presentation.pdf
The Microsoft Excel Parts Presentation.pdfThe Microsoft Excel Parts Presentation.pdf
The Microsoft Excel Parts Presentation.pdf
YvonneRoseEranista
 
UiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer OpportunitiesUiPath Agentic Automation: Community Developer Opportunities
UiPath Agentic Automation: Community Developer Opportunities
DianaGray10
 
Unlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web AppsUnlocking Generative AI in your Web Apps
Unlocking Generative AI in your Web Apps
Maximiliano Firtman
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
TrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI PaymentsTrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI Payments
Trs Labs
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Play It Safe: Manage Security Risks - Google Certificate
Play It Safe: Manage Security Risks - Google CertificatePlay It Safe: Manage Security Risks - Google Certificate
Play It Safe: Manage Security Risks - Google Certificate
VICTOR MAESTRE RAMIREZ
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
Financial Services Technology Summit 2025
Financial Services Technology Summit 2025Financial Services Technology Summit 2025
Financial Services Technology Summit 2025
Ray Bugg
 
Viam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdfViam product demo_ Deploying and scaling AI with hardware.pdf
Viam product demo_ Deploying and scaling AI with hardware.pdf
camilalamoratta
 
Connect and Protect: Networks and Network Security
Connect and Protect: Networks and Network SecurityConnect and Protect: Networks and Network Security
Connect and Protect: Networks and Network Security
VICTOR MAESTRE RAMIREZ
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Ad

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