I'm reading through Platform Cache Internals and Platform Cache Limits with respect to the local cache and the overall partition size.

It appears that the local cache (the application server's in-memory container) is limited to 500 KB for a Session Cache and 1,000 KB for an Org Cache.

For session cache, all cached items are loaded into local cache upon first request. All subsequent interactions use the local cache. Similarly, an org cache get operation retrieves a value from the caching layer and stores it in the local cache. Subsequent requests for this value are retrieved from the local cache. All mutable operations, such as put and remove, are also performed against the local cache. Upon successful completion of the request, mutable operations are committed.

[...] Mutable operations, such as put and remove, are performed against the local cache and are only committed when the entire Apex request is successful.

How does this work when the local cache is smaller than the partition size?

The minimum partition size is 5MB.

The docs imply that you would never be able to access more than 500 KB of session cache per transaction. I.e. "all cached items are loaded into local cache upon first request". So somehow they pick 500 KB out of a 5MB or more of session cache and make that available during the transaction. The other possible 4.5 MB of session cache is then inaccessible?

The org cache makes a bit more sense in that the local cache is populated from the caching layer as the transaction progresses. What seems off there is that I can't populate more that 1 MB of local cache in a transaction. So if I need to cache 3 MB of data into the cache layer I'd need to do so over 3 separate transactions.

1 Answer 1


Yes, you can only interact with 1MB of org cache at a time. This means if you try to write all 3MB of worth of data in one go, you'll only end up committing a third of it. Cache isn't meant to be used to really large volumes of data; if you want to store that much data, consider just writing data to a Document and reading it back later. Caching is meant to be a way to store a small amount of data that was expensive to calculate, not a way to store a lot of commonly used data that was cheap to calculate.

  • My data is coming from an external web service that I have no control over. My expense is in the callout. I need to get pricing data from a web method that is approaching 6MB of data in the response. The reality is I only care about about much less than the 1MB of that data, so it probably won't be an issue. Feb 20, 2018 at 3:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .