SlideShare a Scribd company logo
1 of 10
Cache scope and strategy
By,
Keshav
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 Cachescope

Memory management in oracle
Memory management in oracleMemory management in oracle
Memory management in oracle
Davin Abraham
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Young Alista
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
James Wong
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Tony Nguyen
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Fraboni Ec
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Luis Goldster
 
How analysis services caching works
How analysis services caching worksHow analysis services caching works
How analysis services caching works
Harry Potter
 

Similar to Cachescope (20)

[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
 
Controlling message flow
Controlling message flowControlling message flow
Controlling message flow
 
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...
 
Memory management in oracle
Memory management in oracleMemory management in oracle
Memory management in oracle
 
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
 
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
 
Caching in drupal
Caching in drupalCaching in drupal
Caching in drupal
 
C3 w3
C3 w3C3 w3
C3 w3
 
Redis
RedisRedis
Redis
 
Improve Presto Architectural Decisions with Shadow Cache
 Improve Presto Architectural Decisions with Shadow Cache Improve Presto Architectural Decisions with Shadow Cache
Improve Presto Architectural Decisions with Shadow Cache
 
Building resilient applications
Building resilient applicationsBuilding resilient applications
Building resilient applications
 

Recently uploaded

Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Bert Jan Schrijver
 

Recently uploaded (20)

WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
 
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
WSO2Con2024 - From Blueprint to Brilliance: WSO2's Guide to API-First Enginee...
 
WSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration ToolingWSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration Tooling
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 

Cachescope

  • 1. Cache scope and strategy By, Keshav
  • 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"/>