Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, 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 products and features.
$Cache.Session
Usage
Use {!$Cache.Session} to reference an existing session cache. A session cache consists of cached data that can be reused from one session to the next. Use dot notation to specify the namespace, partition name, or properties of a cached value.
Examples
This output text component retrieves a cached value from the myPartition partition and myNamespace namespace with the key output.
1<apex:outputText value="{!$Cache.Session.myNamespace.myPartition.output}"/>If the cached value is a data structure that has properties or methods, like an Apex list or a custom class, you can access the properties with$Cache.Session by using dot notation. For example, this markup invokes the List.size() Apex method if the value of numbersList is declared as a List.
1<apex:outputText value="{!$Cache.Session.myNamespace.myPartition.numbersList.size}"/>If you’re using CacheBuilder, qualify the key name with the class that implements the CacheBuilder interface and the literal string _B_, in addition to the namespace and partition name. In this example, the class that implements CacheBuilder is called CacheBuilderImpl.
1<apex:outputText value="{!$Cache.Session.myNamespace.myPartition.CacheBuilderImpl_B_key1}"/>