Apex Developer Guide
Summer '26 (API version 67.0)
Spring '26 (API version 66.0)
Winter '26 (API version 65.0)
Summer '25 (API version 64.0)
Spring '25 (API version 63.0)
Winter '25 (API version 62.0)
Summer '24 (API version 61.0)
Spring '24 (API version 60.0)
Winter '24 (API version 59.0)
Summer '23 (API version 58.0)
Spring '23 (API version 57.0)
Winter '23 (API version 56.0)
Summer '22 (API version 55.0)
Spring '22 (API version 54.0)
Winter '22 (API version 53.0)
Summer '21 (API version 52.0)
Spring '21 (API version 51.0)
Winter '21 (API version 50.0)
Summer '20 (API version 49.0)
Spring '20 (API version 48.0)
Winter '20 (API version 47.0)
Summer '19 (API version 46.0)
Spring '19 (API version 45.0)
Winter '19 (API version 44.0)
Summer '18 (API version 43.0)
Spring '18 (API version 42.0)
Winter '18 (API version 41.0)
Summer '17 (API version 40.0)
Spring '17 (API version 39.0)
Winter '17 (API version 38.0)
Summer '16 (API version 37.0)
Spring '16 (API version 36.0)
Winter '16 (API version 35.0)
Summer '15 (API version 34.0)
Spring '15 (API version 33.0)
Winter '15 (API version 32.0)
Spring '14 (API version 30.0)
Release Notes
Actions
Apex Cursors (Beta)
Chatter Answers and Ideas
Moderate Chatter Private Messages with Triggers
Moderate Feed Items with Triggers
Experience Cloud Sites
External Services
Formula Evaluation in Apex
Permission Set Groups
Platform Cache Features
Platform Cache Considerations
Platform Cache Limits
Platform Cache Partitions
Platform Cache Internals
Store and Retrieve Values from the Session Cache
Store and Retrieve Values from the Org Cache
Use a Visualforce Global Variable for the Platform Cache
Safely Cache Values with the CacheBuilder Interface
Platform Cache Best Practices
Support Classes
Territory Management 2.0
Apex Reference
Newer Version Available
Platform Cache
The Lightning Platform Cache layer provides faster performance and better reliability
when caching Salesforce session and org data. Specify what to cache and for how long without
using custom objects and settings or overloading a Visualforce view state. Platform Cache
improves performance by distributing cache space so that some applications or operations don’t
steal capacity from others.
Because Apex runs in a multi-tenant environment with cached data living alongside internally cached data, caching involves minimal disruption to core Salesforce processes.
-
Platform Cache Features
The Platform Cache API lets you store and retrieve data that’s tied to Salesforce sessions or shared across your org. Put, retrieve, or remove cache values by using the Session, Org, SessionPartition, and OrgPartition classes in the Cache namespace. Use the Platform Cache Partition tool in Setup to create or remove org partitions and allocate their cache capacities to balance performance across apps. -
Platform Cache Considerations
Review these considerations when working with Platform Cache. -
Platform Cache Limits
These limits apply when using Platform Cache. -
Platform Cache Partitions
Use Platform Cache partitions to improve the performance of your applications. Partitions allow you to distribute cache space in the way that works best for your applications. Caching data to designated partitions ensures that it’s not overwritten by other applications or less-critical data. -
Platform Cache Internals
Platform Cache uses local cache and a least recently used (LRU) algorithm to improve performance. -
Store and Retrieve Values from the Session Cache
Use the Cache.Session and Cache.SessionPartition classes to manage values in the session cache. To manage values in any partition, use the methods in the Cache.Session class. If you’re managing cache values in one partition, use the Cache.SessionPartition methods instead. -
Store and Retrieve Values from the Org Cache
Use the Cache.Org and Cache.OrgPartition classes to manage values in the org cache. To manage values in any partition, use the methods in the Cache.Org class. If you’re managing cache values in one partition, use the Cache.OrgPartition methods instead. -
Use a Visualforce Global Variable for the Platform Cache
You can access cached values stored in the session or org cache from a Visualforce page with global variables. -
Safely Cache Values with the CacheBuilder Interface
A Platform Cache best practice is to ensure that your Apex code handles cache misses by testing for cache requests that return null. You can write this code yourself. Or, you can use the Cache.CacheBuilder interface, which makes it easy to safely store and retrieve values to a session or org cache. -
Platform Cache Best Practices
Platform Cache can greatly improve performance in your applications. However, it’s important to follow these guidelines to get the best cache performance. In general, it’s more efficient to cache a few large items than to cache many small items separately. Also be mindful of cache limits to prevent unexpected cache evictions.