Platform Cache
A Salesforce caching layer (part of Platform Cache) that stores frequently accessed data in memory using org cache (shared across users) or session cache (per user), reducing SOQL queries and improving application performance.
Definition
A Salesforce caching layer (part of Platform Cache) that stores frequently accessed data in memory using org cache (shared across users) or session cache (per user), reducing SOQL queries and improving application performance.
In plain English
“Platform Cache is a Salesforce caching layer that stores frequently accessed data in memory. It comes in two flavors: org cache (shared across all users) and session cache (per user). Using cache reduces SOQL queries and improves application performance.”
Worked example
Coppermine Mining's custom Apex calculates daily royalty payments using a reference table of 200 lease-property mappings that changes once per quarter. Without caching, every payment-calculation Apex transaction queries the table - burning a SOQL governor limit and adding milliseconds. The dev wraps the table lookup in a Platform Cache org partition: on the first call of the day, the Apex queries the table and writes it to org cache with a 12-hour TTL; on the next 50,000 calls, the lookup hits the cache and returns in microseconds. The cache is shared across all users (org cache, not session cache), so even when 30 different users run the calculation, the table is loaded once. SOQL counts drop 99.6% during the daily payment run.
Why Platform Cache matters
Platform Cache is a Salesforce caching layer (part of Platform Cache) that stores frequently accessed data in memory using org cache (shared across users) or session cache (per user), reducing SOQL queries and improving application performance. Developers use Platform Cache APIs in Apex to store and retrieve cached values, with the platform handling the cache infrastructure. Cached data has a configured time-to-live and gets evicted when the cache fills up.
Platform Cache is valuable for performance optimization when the same data is accessed repeatedly. Org cache is appropriate for data shared across users (like configuration values, lookup data, expensive query results). Session cache is appropriate for per-user data (like user-specific calculations or context). Mature Apex code uses Platform Cache for legitimate caching scenarios while being careful not to cache stale data or rely on cache for correctness.
How organizations use Platform Cache
Uses Platform Cache to store expensive lookup query results that are referenced frequently across user requests.
Built session cache patterns for user-specific calculations that would be slow to recompute on every page load.
Treats Platform Cache as a performance optimization tool with careful consideration of staleness implications.
Trust & references
Straight from the source - Salesforce's reference material on Platform Cache.
- Platform CacheSalesforce Developers
- Platform Cache PartitionsSalesforce Developers
About the Author
Dipojjal Chakrabarti is a B2C Solution Architect with 29 Salesforce certifications and over 13 years in the Salesforce ecosystem. He runs salesforcedictionary.com to help admins, developers, architects, and cert/interview candidates sharpen their fundamentals. More about Dipojjal.
Test your knowledge
Q1. What is Platform Cache?
Q2. What's the difference between org and session cache?
Q3. What should you not do with Platform Cache?
Discussion
Loading discussion…