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.