SlideShare a Scribd company logo
1 of 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!

More Related Content

More from 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
 

More from 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
 

Recently uploaded

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 

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

Editor's Notes

  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: