Newer Version Available
Platform Cache Partitions
To use Platform Cache, first set up partitions using the Platform Cache Partition tool in Setup. Once you’ve set up partitions, you can add, access, and remove data from them using the Platform Cache Apex API.
To access the Partition tool in Setup, enter Platform Cache in the Quick Find box, then select Platform Cache.
- Request trial cache.
- Create, edit, or delete cache partitions.
- Allocate the session cache and org cache capacities of each partition to balance performance across apps.
- View a snapshot of the org’s current cache capacity, breakdown, and partition allocations (in KB or MB).
- View details about each partition.
- Make any partition the default partition.
To use Platform Cache, create at least one partition. Each partition has one session cache and one org cache segment and you can allocate separate capacity to each segment. Session cache can be used to store data for individual user sessions, and org cache is for data that any users in an org can access. You can distribute your org’s cache space across any number of partitions. Session and org cache allocations can be zero, or five or greater, and they must be whole numbers. The sum of all partition allocations, including the default partition, equals the Platform Cache total allocation. The total allocated capacity of all cache segments must be less than or equal to the org’s overall capacity.
You can define any partition as the default partition, but you can have only one default partition. When the capacity of the default partition is used up and is zero, you can’t create more partitions. When a partition has no allocation, cache operations (such as get and put) are not invoked and no error is returned.
When performing cache operations within the default partition, you can omit the partition name from the key.
After you set up partitions, you can use Apex code to perform cache operations on a partition. For example, use the Session.Partition and Org.Partition classes to put, retrieve, or remove values on a specific partition’s cache. Use Cache.Session and Cache.Org to get a partition or perform cache operations by using a fully qualified key.
Packaging Platform Cache Partitions
If you’re working with managed packages, we recommend using Branch Packaging Orgs to share a namespace across partitions. This feature lets you maintain multiple orgs or partitions as “branches” of your primary org. For information about Branch Packaging Orgs, contact Salesforce.