Newer Version Available
Platform Cache Features
-
Session cache—Stores data for individual user sessions. For example, in an app
that finds customers within specified territories, the calculations that run while users
browse different locations on a map are reused.
A session cache lives alongside a user session. The maximum life of a session is eight hours. A session cache expires when its specified time-to-live (ttlsecs value) is reached or when the session expires after eight hours, whichever comes first.
-
Org cache—Stores data that any user in an org reuses. For example, the contents
of navigation bars that dynamically display menu items based on user profile are
reused.
Unlike a session cache, an org cache is accessible across sessions, requests, and org users and profiles. An org cache expires when its specified time-to-live (ttlsecs value) is reached.
- Reused throughout a session
- Static (not rapidly changing)
- Otherwise expensive to retrieve
For both session and org caches, you can construct calls so that cached data in one namespace isn’t overwritten by similar data in another. Optionally use the Cache.Visibility enumeration to specify whether Apex code can access cached data in a namespace outside of the invoking namespace.
Each cache operation depends on the Apex transaction within which it runs. If the entire transaction fails, all cache operations in that transaction are rolled back.