$Cache.Session

A global merge field to access an org’s session cache from a Visualforce page. Retrieve cached values from a specified partition’s session cache in the referenced org.

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 home partition or properties of a cached value.

Examples

This is an output text component that retrieves a cached value from the default partition with the key output.

<apex:outputText value="{!$Cache.Session.output}"/>
<!-- If the organization has a namespace ns1, use the following. -->
<apex:outputText value="{!$Cache.Session.ns1.default.output}"/>

If the cached value is a data structure that has properties or methods, like an Apex List or a custom class, those properties can be accessed 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.

<apex:outputText value="{!$Cache.Session.local.default.numbersList.size}"/>
Previous
Next