2. Agenda:
• What is platform cache
• When Can I Use Platform Cache?
• What Are Cache Partitions?
• Use of Org & Session Cache
• How can we read/write data in cache partition
• Platform Cache consideration
3. What is platform Cache
• Platform Cache is a memory layer that stores
Salesforce session and org data for later access.
• When you use Platform Cache, your applications
can run faster because they store reusable data
in memory.
• Applications can quickly access this data; they
don’t need to duplicate calculations and requests
to the database on subsequent transactions.
4. What Are the Types of Platform Cache?
• There are two types of Platform Cache:
org cache and session cache.
• Org Cache: Org cache stores org-wide data that
anyone in the org can use. Org cache is
accessible across sessions, requests, and org
users and profiles.
• Session Cache: Session cache stores data for an
individual user and is tied to that user’s session.
5. When Can I Use Platform Cache?
• You can use Platform Cache in your code almost
anywhere you access the same data over and
over. Using cached data improves the
performance of your app.
• Reused throughout a session, or reused across all
users and requests.
• Expensive to compute or retrieve
• Store Data That Doesn’t Change Often
6. What Are Cache Partitions?
• Partitions let you allocate cache space to
balance usage and performance across apps.
• Caching data to designated partitions ensures
that the cache space isn’t overwritten by other
apps or by less critical data.
•
8. Store and retrieve values in
the org and session cache.
• // Get partition
• Cache.Org Class
• Cache.session Class
9. • Cache Key Name Format:
Namespace.Partition.Key
• // Add cache value to the partition.
• Cache.Org.put(Namespace.Partition.Key, value,
timestamp(Optional));
• // Retrieve cache value from the partition
• String cachedRate =
(DataType)orgPart.get('Namespace.Partition.Ke
y');
10. Platform Cache
Considerations
• Always handle the cache miss
• Data in the cache isn’t encrypted.
• Partitions must adhere to the limits within
Salesforce.
• The session cache can store values up to eight
hours. The org cache can store values up to 48
hours.