---
schema_version: "1"
id: 307f26a8bb9e02a5512a541fff034c0f34aaed8c9a45cb19a5d198a6fdcb2519
title: Use a Visualforce Global Variable for the Platform Cache
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/apex_platform_cache_global_variable.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_platform_cache_global_variable.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: c4141faae52a14b544bafa457c0951afb056fa3cf9d7ace6d32cf9a77e6d420f
description: You can access cached values stored in the session or org cache from a Visualforce page with global variables.
---
# 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.

You can use either the $Cache.Session or $Cache.Org global variable. Include the global variable’s fully qualified key name with the namespace and partition name.

This output text component retrieves a session cache value using the global variable’s namespace, partition, and key.

<apex:outputText value="{!$Cache.Session.myNamespace.myPartition.key1}"/>

This example is similar but uses the $Cache.Org global variable to retrieve a value from the org cache.

<apex:outputText value="{!$Cache.Org.myNamespace.myPartition.key1}"/>

![Note](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/images/icon_note.png)

#### Note

The remaining examples show how to access the session cache using the $Cache.Session global variable. The equivalent org cache examples are the same except that you use the $Cache.Org global variable instead.

Unlike with Apex methods, you can’t omit the myNamespace.myPartition prefix to reference the default partition in the org.

If a namespace isn’t defined for the org, use local to refer to the org’s namespace.

<apex:outputText value="{!$Cache.Session.local.myPartition.key1}"/>

The cached value is sometimes a data structure that has properties or methods, like an Apex list or a custom class. In this case, you can access the properties in the $Cache.Session or $Cache.Org expression 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.myPartition.numbersList.size}"/>

This example accesses the value property on the myData cache value that is declared as a custom class.

<apex:outputText value="{!$Cache.Session.local.myPartition.myData.value}"/>

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.

<apex:outputText value="{!$Cache.Session.myNamespace.myPartition.CacheBuilderImpl\_B\_key1}"/>