Accessing Cache in a SharePoint List Item event Receiver
There are times when for performance reasons you might want to store things in the Application cache. The same applies to SharePoint also.
In our recent project we had to store some configuration information in a SharePoint list that would rarely change. So instead of reading it from the SP list every time we decided to store it in the Cache. This was easy to do as we did it inside a web part. And since we can hook up to the List modifications through Event Receivers we planned to clear the cache in the event code.
But what we dint realize was that there was no easy way to get to the application cache L inside the event receiver code. SPContext is null.
So what do you do ? After some research I found out that you can access the cache through HttpRuntime.Cache. Also removing a cache value through cache["Key"] will throw an exception. You would have to say cache.Remove("Key")
HTH
Hari


Comments