SlideShare una empresa de Scribd logo
1 de 34
Boost your App with Platform Cache
Learn How Caching Can Improve Your App’s Performance
by Daniel Stange * DIA die.interaktiven
#CD19
20x certified
System & Application Architect
Frankfurt User Group Leader
@stangomat
linked.in/daniel-stange
github.com/dstdia
Daniel Stange
Technical Architect
DIA die.interaktiven
#CD19
● Platform Cache? But why?
● Key Concepts
● Getting Started with Platform Cache (Demo / Code!)
● When to Use (and when not to use) Platform Cache
Agenda
#CD19
● Learn using the platform cache can boost your app‘s performance
significantly
● Understand which kind of data to put in the cache
● Know the obstacles when you use to the platform cache and
prepare for cache misses and unexpected results
Key Takeaways
#CD19
Platform Cache?
But why?
#CD19
Avg. to fetch 10000 records
as a Map through SOQL
182-370ms
1.8 to 5.7x
Faster Access
65-97ms
Avg. to fetch the same
map from the Org cache
Impact for read access to data
(EE Scratch Org on CS83 / EE Dev Sandbox on CS86)
#CD19
DB vs. Cache Retrieve / per Item
Impact of bulkification (100 retrieved values)
DB: Initial 367ms => 3,67ms per item access
Cache: Initial 117ms => 1,17ms per item access
DB: avg. 11,52ms
Cache: avg. 3.67ms
#CD19
Key Concepts
#CD19
● Simple & temporary Key-Value-Storage (Map<String, Object>)
● Quite Easy to implement ANY cache strategy
=> but Fairly Easy to design a GOOD, sustainable strategy
● By default VISIBLE and MUTABLE
=> but can be RESTRICTED and set to IMMUTABLE
Platform Cache
#CD19
● PREPARABLE - REUSABLE
● Static: Not changing frequently
● Frequently needed in operations
● Expensive to get (in terms of system limits)
● e,g, Taxonomies, Schedules, Mappings, Conversion Rates, etc.
Data to Cache
#CD19
Cache Types
ORG
one cache for all
users and contexts
longer TTL
SESSION
scoped per user
Session
TTL = Session
length
#CD19
ORG: 24 hrs
DEFAULT
TTL
Time-to-Live (TTL)
ORG: 5 min
MINIMUM
TTL
SESSION: 5
min
ORG: 48 hrs
MAXIMUM
TTL
SESSION: 8
hrs
#CD19
LRU: Least Recently Used Eviction Strategy
1
4
3
7
5
6
ORDER OF LAST ACCESS
2
CACHE CAPACITY
#CD19
How to get started
#CD19
● Enterprise Editions Sandboxs come with a 10 MB capacity
● Request a trial capacity if you are using a Developer Org or Scratch
Org
● Trailhead: “Platform Cache Basics”
bit.ly/cachetrail
Preparation Work
#CD19
Place your screenshot here
Cache
.[Org/Session]
.put(
Namespace
.PartitionName
.Key,
Object
);
Store
#CD19
Place your screenshot here
Retrieve
Cache
.[Org/Session]
.get(
Namespace
.PartitionName
.Key
);
#CD19
Sample Implementation and Benchmark Scripts at
https://github.com/dstdia/PlatformCache
Demo
#CD19
Place your screenshot here
Sample Sales District
◇Everything with
Country = DE and
PostalCode LIKE ‘35%’
should be assigned
and have Nils as an
Owner.
https://github.com/
dstdia/PlatformCache
#CD19
Place your screenshot here
Creating an Account
◇Postal Code starts with
35 and Country = DE
◇Should end up in
Central Sample District
being assigned
https://github.com/
dstdia/PlatformCache
#CD19
Place your screenshot here
And there it is!
https://github.com/
dstdia/PlatformCache
#CD19
https://github.com/
dstdia/PlatformCache
#CD19
https://github.com/
dstdia/PlatformCache
#CD19
https://github.com/
dstdia/PlatformCache
#CD19
Considerations
#CD19
● It‘s still a cache, not a database.
● It is short lived and per default visible and mutable
● Understand the key concepts of the platform cache
(in particular TTL, LRU)
● Expect the cache to fail you.
● What’s your strategy to invalidate cache?
Nice! Easy! Fast! Where‘s the catch?
#CD19
● The Cache will go away... Schedule a Cache Rebuild < TTL
● Cached items will be pushed out… Use the CacheBuilder interface
● Cached data goes stale… Rebuild From Triggers
● Cached items must adhere to the 100kB size limits
Reduce memory footprint by using Apex Classes instead of
sObject or reduce the number of queried fields
Build your Strategies
#CD19
List<CachedProduct>
cachedProducts;
public class CachedProduct {
String name;
String productCode;
Decimal leadTime;
}
Apex Classes vs. sObjects
List<Product2> products =
[SELECT Name,
ProductCode,
LeadTime
FROM Product2];
#CD19
(Same query, using an Apex defined type)
Size matters – 100kb equals
12.5k wrapped items
9k sObjectsProduct2 records with ID, Name, ProductCode queried
#CD19
● Don‘t use the cache as a fast, limit-free database.
● Don‘t use it as temporary storage for transactional data
● No items larger than 100kB
● Cached Items are not persisted – don‘t rely on them being there.
● Unless flagged as immutable, don’t rely on the integrity of cached
items
Repeat after me… :-)
#CD19
● Cache lists or maps of objects rather than single objects.
Tradeoff:
Better performance of fewer, larger operations
vs. 100kB item size limit
● Use a wrapper class to reduce sObject overhead
● Use the fully qualified name of your cache partition
● Consider using the ‘immutable‘ flag and the visibility enum
Best Practices
#CD19
● Developer Documentation: bit.ly/cachedoc
● Trailhead: bit.ly/cachetrail
● Session Code: github.com/dstdia/PlatformCache/
● Keir Bowden’s blog post: bit.ly/cache-buzzard
● Josh Kaplan‘s blog post: bit.ly/cache-sfblog
● Amit Chaudhary: http://bit.ly/cache-amit
Further Reading
#CD19
Connect with me
● @stangomat
● Daniel.stange@die.interaktiven.de
● github.com/dstdia
Sample Code from the session:
https://github.com/dstdia/PlatformCache
Q&A
Thank you!

Más contenido relacionado

Más de CzechDreamin

ChatGPT … How Does it Flow?, Mark Jones
ChatGPT … How Does it Flow?, Mark JonesChatGPT … How Does it Flow?, Mark Jones
ChatGPT … How Does it Flow?, Mark JonesCzechDreamin
 
Real-time communication with Account Engagement (Pardot). Marketers meet deve...
Real-time communication with Account Engagement (Pardot). Marketers meet deve...Real-time communication with Account Engagement (Pardot). Marketers meet deve...
Real-time communication with Account Engagement (Pardot). Marketers meet deve...CzechDreamin
 
Black Hat Session: Exploring and Exploiting Aura based Experiences, Christian...
Black Hat Session: Exploring and Exploiting Aura based Experiences, Christian...Black Hat Session: Exploring and Exploiting Aura based Experiences, Christian...
Black Hat Session: Exploring and Exploiting Aura based Experiences, Christian...CzechDreamin
 
Sales methodology for Salesforce Opportunity, Georgy Avilov
Sales methodology for Salesforce Opportunity, Georgy AvilovSales methodology for Salesforce Opportunity, Georgy Avilov
Sales methodology for Salesforce Opportunity, Georgy AvilovCzechDreamin
 
5 key ideas for robust and flexible REST API integrations with Apex, Lucian M...
5 key ideas for robust and flexible REST API integrations with Apex, Lucian M...5 key ideas for robust and flexible REST API integrations with Apex, Lucian M...
5 key ideas for robust and flexible REST API integrations with Apex, Lucian M...CzechDreamin
 
Report & Dashboard REST API : Get your report accessible anywhere !, Romain Q...
Report & Dashboard REST API : Get your report accessible anywhere !, Romain Q...Report & Dashboard REST API : Get your report accessible anywhere !, Romain Q...
Report & Dashboard REST API : Get your report accessible anywhere !, Romain Q...CzechDreamin
 
No Such Thing as Best Practice in Design, Nati Asher and Pat Fragoso
No Such Thing as Best Practice in Design, Nati Asher and Pat FragosoNo Such Thing as Best Practice in Design, Nati Asher and Pat Fragoso
No Such Thing as Best Practice in Design, Nati Asher and Pat FragosoCzechDreamin
 
Why do you Need to Migrate to Salesforce Flow?, Andrew Cook
Why do you Need to Migrate to Salesforce Flow?, Andrew CookWhy do you Need to Migrate to Salesforce Flow?, Andrew Cook
Why do you Need to Migrate to Salesforce Flow?, Andrew CookCzechDreamin
 
Be kind to your future admin self, Silvia Denaro & Nathaniel Sombu
Be kind to your future admin self, Silvia Denaro & Nathaniel SombuBe kind to your future admin self, Silvia Denaro & Nathaniel Sombu
Be kind to your future admin self, Silvia Denaro & Nathaniel SombuCzechDreamin
 
Monitoring Automation Performance in Marketing Cloud Engagement, Daniela Vrbk...
Monitoring Automation Performance in Marketing Cloud Engagement, Daniela Vrbk...Monitoring Automation Performance in Marketing Cloud Engagement, Daniela Vrbk...
Monitoring Automation Performance in Marketing Cloud Engagement, Daniela Vrbk...CzechDreamin
 
The minimum-profile approach – the modern way to design an efficient security...
The minimum-profile approach – the modern way to design an efficient security...The minimum-profile approach – the modern way to design an efficient security...
The minimum-profile approach – the modern way to design an efficient security...CzechDreamin
 
Restriction Rules – The Whole Picture, Louise Lockie
Restriction Rules – The Whole Picture, Louise LockieRestriction Rules – The Whole Picture, Louise Lockie
Restriction Rules – The Whole Picture, Louise LockieCzechDreamin
 
Introduction to Custom Journey Builder Activities, Orkhan Alakbarli
Introduction to Custom Journey Builder Activities, Orkhan AlakbarliIntroduction to Custom Journey Builder Activities, Orkhan Alakbarli
Introduction to Custom Journey Builder Activities, Orkhan AlakbarliCzechDreamin
 
Taking control of your queries with GraphQL, Alba Rivas
Taking control of your queries with GraphQL, Alba RivasTaking control of your queries with GraphQL, Alba Rivas
Taking control of your queries with GraphQL, Alba RivasCzechDreamin
 
“Soft Skills” are the new “Hard Skills” – Tips & Tricks for Salesforce Projec...
“Soft Skills” are the new “Hard Skills” – Tips & Tricks for Salesforce Projec...“Soft Skills” are the new “Hard Skills” – Tips & Tricks for Salesforce Projec...
“Soft Skills” are the new “Hard Skills” – Tips & Tricks for Salesforce Projec...CzechDreamin
 
The Art of Discovery – Why Requirements Matter, Pallavi Agarwal
The Art of Discovery – Why Requirements Matter, Pallavi AgarwalThe Art of Discovery – Why Requirements Matter, Pallavi Agarwal
The Art of Discovery – Why Requirements Matter, Pallavi AgarwalCzechDreamin
 
Effective coding approaches with Salesforce: Combining features for maximum i...
Effective coding approaches with Salesforce: Combining features for maximum i...Effective coding approaches with Salesforce: Combining features for maximum i...
Effective coding approaches with Salesforce: Combining features for maximum i...CzechDreamin
 
Human Centred Design and Architecting a Solution that stands the test of time...
Human Centred Design and Architecting a Solution that stands the test of time...Human Centred Design and Architecting a Solution that stands the test of time...
Human Centred Design and Architecting a Solution that stands the test of time...CzechDreamin
 
Skill Based Routing – The Complete Manual, Mieszko Rożej
Skill Based Routing – The Complete Manual, Mieszko RożejSkill Based Routing – The Complete Manual, Mieszko Rożej
Skill Based Routing – The Complete Manual, Mieszko RożejCzechDreamin
 
Marketing Data Enablement Strategies with Data Cloud, Lusine Grigoryan
Marketing Data Enablement Strategies with Data Cloud, Lusine GrigoryanMarketing Data Enablement Strategies with Data Cloud, Lusine Grigoryan
Marketing Data Enablement Strategies with Data Cloud, Lusine GrigoryanCzechDreamin
 

Más de CzechDreamin (20)

ChatGPT … How Does it Flow?, Mark Jones
ChatGPT … How Does it Flow?, Mark JonesChatGPT … How Does it Flow?, Mark Jones
ChatGPT … How Does it Flow?, Mark Jones
 
Real-time communication with Account Engagement (Pardot). Marketers meet deve...
Real-time communication with Account Engagement (Pardot). Marketers meet deve...Real-time communication with Account Engagement (Pardot). Marketers meet deve...
Real-time communication with Account Engagement (Pardot). Marketers meet deve...
 
Black Hat Session: Exploring and Exploiting Aura based Experiences, Christian...
Black Hat Session: Exploring and Exploiting Aura based Experiences, Christian...Black Hat Session: Exploring and Exploiting Aura based Experiences, Christian...
Black Hat Session: Exploring and Exploiting Aura based Experiences, Christian...
 
Sales methodology for Salesforce Opportunity, Georgy Avilov
Sales methodology for Salesforce Opportunity, Georgy AvilovSales methodology for Salesforce Opportunity, Georgy Avilov
Sales methodology for Salesforce Opportunity, Georgy Avilov
 
5 key ideas for robust and flexible REST API integrations with Apex, Lucian M...
5 key ideas for robust and flexible REST API integrations with Apex, Lucian M...5 key ideas for robust and flexible REST API integrations with Apex, Lucian M...
5 key ideas for robust and flexible REST API integrations with Apex, Lucian M...
 
Report & Dashboard REST API : Get your report accessible anywhere !, Romain Q...
Report & Dashboard REST API : Get your report accessible anywhere !, Romain Q...Report & Dashboard REST API : Get your report accessible anywhere !, Romain Q...
Report & Dashboard REST API : Get your report accessible anywhere !, Romain Q...
 
No Such Thing as Best Practice in Design, Nati Asher and Pat Fragoso
No Such Thing as Best Practice in Design, Nati Asher and Pat FragosoNo Such Thing as Best Practice in Design, Nati Asher and Pat Fragoso
No Such Thing as Best Practice in Design, Nati Asher and Pat Fragoso
 
Why do you Need to Migrate to Salesforce Flow?, Andrew Cook
Why do you Need to Migrate to Salesforce Flow?, Andrew CookWhy do you Need to Migrate to Salesforce Flow?, Andrew Cook
Why do you Need to Migrate to Salesforce Flow?, Andrew Cook
 
Be kind to your future admin self, Silvia Denaro & Nathaniel Sombu
Be kind to your future admin self, Silvia Denaro & Nathaniel SombuBe kind to your future admin self, Silvia Denaro & Nathaniel Sombu
Be kind to your future admin self, Silvia Denaro & Nathaniel Sombu
 
Monitoring Automation Performance in Marketing Cloud Engagement, Daniela Vrbk...
Monitoring Automation Performance in Marketing Cloud Engagement, Daniela Vrbk...Monitoring Automation Performance in Marketing Cloud Engagement, Daniela Vrbk...
Monitoring Automation Performance in Marketing Cloud Engagement, Daniela Vrbk...
 
The minimum-profile approach – the modern way to design an efficient security...
The minimum-profile approach – the modern way to design an efficient security...The minimum-profile approach – the modern way to design an efficient security...
The minimum-profile approach – the modern way to design an efficient security...
 
Restriction Rules – The Whole Picture, Louise Lockie
Restriction Rules – The Whole Picture, Louise LockieRestriction Rules – The Whole Picture, Louise Lockie
Restriction Rules – The Whole Picture, Louise Lockie
 
Introduction to Custom Journey Builder Activities, Orkhan Alakbarli
Introduction to Custom Journey Builder Activities, Orkhan AlakbarliIntroduction to Custom Journey Builder Activities, Orkhan Alakbarli
Introduction to Custom Journey Builder Activities, Orkhan Alakbarli
 
Taking control of your queries with GraphQL, Alba Rivas
Taking control of your queries with GraphQL, Alba RivasTaking control of your queries with GraphQL, Alba Rivas
Taking control of your queries with GraphQL, Alba Rivas
 
“Soft Skills” are the new “Hard Skills” – Tips & Tricks for Salesforce Projec...
“Soft Skills” are the new “Hard Skills” – Tips & Tricks for Salesforce Projec...“Soft Skills” are the new “Hard Skills” – Tips & Tricks for Salesforce Projec...
“Soft Skills” are the new “Hard Skills” – Tips & Tricks for Salesforce Projec...
 
The Art of Discovery – Why Requirements Matter, Pallavi Agarwal
The Art of Discovery – Why Requirements Matter, Pallavi AgarwalThe Art of Discovery – Why Requirements Matter, Pallavi Agarwal
The Art of Discovery – Why Requirements Matter, Pallavi Agarwal
 
Effective coding approaches with Salesforce: Combining features for maximum i...
Effective coding approaches with Salesforce: Combining features for maximum i...Effective coding approaches with Salesforce: Combining features for maximum i...
Effective coding approaches with Salesforce: Combining features for maximum i...
 
Human Centred Design and Architecting a Solution that stands the test of time...
Human Centred Design and Architecting a Solution that stands the test of time...Human Centred Design and Architecting a Solution that stands the test of time...
Human Centred Design and Architecting a Solution that stands the test of time...
 
Skill Based Routing – The Complete Manual, Mieszko Rożej
Skill Based Routing – The Complete Manual, Mieszko RożejSkill Based Routing – The Complete Manual, Mieszko Rożej
Skill Based Routing – The Complete Manual, Mieszko Rożej
 
Marketing Data Enablement Strategies with Data Cloud, Lusine Grigoryan
Marketing Data Enablement Strategies with Data Cloud, Lusine GrigoryanMarketing Data Enablement Strategies with Data Cloud, Lusine Grigoryan
Marketing Data Enablement Strategies with Data Cloud, Lusine Grigoryan
 

Último

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

Boost your App with Platform Cache Learn how to leverage the platform cache to improve your app's performance, Daniel Stange

  • 1. Boost your App with Platform Cache Learn How Caching Can Improve Your App’s Performance by Daniel Stange * DIA die.interaktiven
  • 2. #CD19 20x certified System & Application Architect Frankfurt User Group Leader @stangomat linked.in/daniel-stange github.com/dstdia Daniel Stange Technical Architect DIA die.interaktiven
  • 3. #CD19 ● Platform Cache? But why? ● Key Concepts ● Getting Started with Platform Cache (Demo / Code!) ● When to Use (and when not to use) Platform Cache Agenda
  • 4. #CD19 ● Learn using the platform cache can boost your app‘s performance significantly ● Understand which kind of data to put in the cache ● Know the obstacles when you use to the platform cache and prepare for cache misses and unexpected results Key Takeaways
  • 6. #CD19 Avg. to fetch 10000 records as a Map through SOQL 182-370ms 1.8 to 5.7x Faster Access 65-97ms Avg. to fetch the same map from the Org cache Impact for read access to data (EE Scratch Org on CS83 / EE Dev Sandbox on CS86)
  • 7. #CD19 DB vs. Cache Retrieve / per Item Impact of bulkification (100 retrieved values) DB: Initial 367ms => 3,67ms per item access Cache: Initial 117ms => 1,17ms per item access DB: avg. 11,52ms Cache: avg. 3.67ms
  • 9. #CD19 ● Simple & temporary Key-Value-Storage (Map<String, Object>) ● Quite Easy to implement ANY cache strategy => but Fairly Easy to design a GOOD, sustainable strategy ● By default VISIBLE and MUTABLE => but can be RESTRICTED and set to IMMUTABLE Platform Cache
  • 10. #CD19 ● PREPARABLE - REUSABLE ● Static: Not changing frequently ● Frequently needed in operations ● Expensive to get (in terms of system limits) ● e,g, Taxonomies, Schedules, Mappings, Conversion Rates, etc. Data to Cache
  • 11. #CD19 Cache Types ORG one cache for all users and contexts longer TTL SESSION scoped per user Session TTL = Session length
  • 12. #CD19 ORG: 24 hrs DEFAULT TTL Time-to-Live (TTL) ORG: 5 min MINIMUM TTL SESSION: 5 min ORG: 48 hrs MAXIMUM TTL SESSION: 8 hrs
  • 13. #CD19 LRU: Least Recently Used Eviction Strategy 1 4 3 7 5 6 ORDER OF LAST ACCESS 2 CACHE CAPACITY
  • 14. #CD19 How to get started
  • 15. #CD19 ● Enterprise Editions Sandboxs come with a 10 MB capacity ● Request a trial capacity if you are using a Developer Org or Scratch Org ● Trailhead: “Platform Cache Basics” bit.ly/cachetrail Preparation Work
  • 16. #CD19 Place your screenshot here Cache .[Org/Session] .put( Namespace .PartitionName .Key, Object ); Store
  • 17. #CD19 Place your screenshot here Retrieve Cache .[Org/Session] .get( Namespace .PartitionName .Key );
  • 18. #CD19 Sample Implementation and Benchmark Scripts at https://github.com/dstdia/PlatformCache Demo
  • 19. #CD19 Place your screenshot here Sample Sales District ◇Everything with Country = DE and PostalCode LIKE ‘35%’ should be assigned and have Nils as an Owner. https://github.com/ dstdia/PlatformCache
  • 20. #CD19 Place your screenshot here Creating an Account ◇Postal Code starts with 35 and Country = DE ◇Should end up in Central Sample District being assigned https://github.com/ dstdia/PlatformCache
  • 21. #CD19 Place your screenshot here And there it is! https://github.com/ dstdia/PlatformCache
  • 26. #CD19 ● It‘s still a cache, not a database. ● It is short lived and per default visible and mutable ● Understand the key concepts of the platform cache (in particular TTL, LRU) ● Expect the cache to fail you. ● What’s your strategy to invalidate cache? Nice! Easy! Fast! Where‘s the catch?
  • 27. #CD19 ● The Cache will go away... Schedule a Cache Rebuild < TTL ● Cached items will be pushed out… Use the CacheBuilder interface ● Cached data goes stale… Rebuild From Triggers ● Cached items must adhere to the 100kB size limits Reduce memory footprint by using Apex Classes instead of sObject or reduce the number of queried fields Build your Strategies
  • 28. #CD19 List<CachedProduct> cachedProducts; public class CachedProduct { String name; String productCode; Decimal leadTime; } Apex Classes vs. sObjects List<Product2> products = [SELECT Name, ProductCode, LeadTime FROM Product2];
  • 29. #CD19 (Same query, using an Apex defined type) Size matters – 100kb equals 12.5k wrapped items 9k sObjectsProduct2 records with ID, Name, ProductCode queried
  • 30. #CD19 ● Don‘t use the cache as a fast, limit-free database. ● Don‘t use it as temporary storage for transactional data ● No items larger than 100kB ● Cached Items are not persisted – don‘t rely on them being there. ● Unless flagged as immutable, don’t rely on the integrity of cached items Repeat after me… :-)
  • 31. #CD19 ● Cache lists or maps of objects rather than single objects. Tradeoff: Better performance of fewer, larger operations vs. 100kB item size limit ● Use a wrapper class to reduce sObject overhead ● Use the fully qualified name of your cache partition ● Consider using the ‘immutable‘ flag and the visibility enum Best Practices
  • 32. #CD19 ● Developer Documentation: bit.ly/cachedoc ● Trailhead: bit.ly/cachetrail ● Session Code: github.com/dstdia/PlatformCache/ ● Keir Bowden’s blog post: bit.ly/cache-buzzard ● Josh Kaplan‘s blog post: bit.ly/cache-sfblog ● Amit Chaudhary: http://bit.ly/cache-amit Further Reading
  • 33. #CD19 Connect with me ● @stangomat ● Daniel.stange@die.interaktiven.de ● github.com/dstdia Sample Code from the session: https://github.com/dstdia/PlatformCache Q&A

Notas del editor

  1. What to expect? Intermediate Level Coding Sklills, Apex Devs
  2. What to expect? Intermediate Level Coding Sklills, Apex Devs
  3. Doing the same exercise again in 2019, the results are a bit more grounded. Still, maintaining a layer of fast cache is two to six times faster than direct database access, and that’s probably more than enough.
  4. What I did next was preparing a read-through cache, and then hammered the database a bit. you can see clearly how the cache - after an initial spike to rebuild the cache was constantly just around three times faster that read access to the databse.
  5. Now that you have an idea why you probably want to spend some time with the cache - here’s what’s behind it: