I have a SharePoint 2010 Farm and want to use object caching for my own custom objects.
Since it's an ASP.net Application at it's core, I could use HttpRuntime.Cache. On the other hand, SharePoint 2010 offers it's own SPCache.
Why would I choose SPCache over the HttpRuntime.Cache one?
FYI, I went with SPCache at the end. It is indeed a very unusual SharePoint class: Well documented, simple and straight-forward to use, painless to manage.
It does offer the one thing HttpRuntime.Cache does not do: Allowing me to create my own subcaches and invalidating this without wiping the entire HttpCache.
I could achieve the same using a Dictionary inside the HttpCache, but locking around that has some potential issues. I reflected on the SPCache and found a solid, thread safe implementation, so that's what I went with.
As a caveat: SPCache seems to be SharePoint Server only, not for Foundation.
This question is intriguing.
It sounds like you should not use SPCache (but usually the msdn page would say "not intended to be used by user code".)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With