I am building a SharePoint sandbox solution which consists of multiple web parts. I want to be able to somehow cache POCO objects (Plain Old CLR Objects) in such a way that the cache is persisted across full page requests and the cache works in SharePoint online as well.

I have looked at the following mechanisms:

Saving files on the file system or in Isolated Storage - doesn't work because the System.IO namespace seems to be blocked in sandbox solutions.

Using the ASP.NET Cache/Session/Application infrastructure - doesn't work, the cache is reset every time a new page request is made.

Using the Microsoft.Office.Server.ObjectCache.SPCache infrastructure - doesn't seem to work, the cache is reset in the same way as with ASP.NET cache.

2 Answers
2

Each request is marshalled from ASP.NET/SharePoint to a specific Sandbox process. These processes and AppDomains are not guaranteed to be the same or even on the same machine, so any kind of in-memory cache is out of question.