SlideShare ist ein Scribd-Unternehmen logo
1 von 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!

Weitere ähnliche Inhalte

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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 WorkerThousandEyes
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
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
 
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 Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 

Kürzlich hochgeladen (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
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 Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

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

Hinweis der Redaktion

  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: