Platform Cache Partitions

Partitions improve application performance by distributing cache space in the best way for your org. Cache data to designated partitions to ensure that it’s not overwritten by other applications or less-critical data. Create and manage org partitions declaratively by using the Platform Cache Partition tool in Setup.

To use the Force.com platform cache, you need at least one partition. You can distribute your org’s cache space across any number of partitions. Each partition has one session cache and one org cache segment. Each cache segment has its own capacity and time-to-live attributes and uses an LRU algorithm.

First create at least one partition and then allocate cache capacity to that partition’s session cache and org cache segments. Session and org cache allocations can be zero or greater than five and 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 more capacity, cache operations are not performed and no error is returned.

When performing cache operations within the default partition, you can omit the partition name from the key.

Note

Note

If platform cache code is intended for a package, don’t use the default partition in the package. Instead, explicitly reference and package a non-default partition. Any package containing the default partition can’t be deployed.

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. It eliminates the need to fully qualify key names when referencing partitions. For information about Branch Packaging Orgs, contact Salesforce.

Note

Note

We provide this feature to selected customers through a pilot program that requires agreement to specific terms and conditions. To be nominated to participate in the program, contact Salesforce. Because pilot programs are subject to change, we can’t guarantee acceptance. This pilot feature isn’t generally available, as referenced in this document or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available features.

To access the Partition tool in Setup, enter Platform Cache in the Quick Find box, then select Platform Cache.

Use the Partition tool to:
  • Create or remove org partitions.
  • Allocate the session cache and org cache capacities of each partition to balance performance across apps.
  • View a snapshot of all cache partitions with their current and total capacities.
  • View details about each partition.
  • Make any partition the default partition.

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.

Previous
Next