I'm writing an ASP.NET MVC4
app that stores some security data in HttpContext.Current.Cache.
I then propose to use write a background thread to synchronise what's in the cache with the database. This provides a recovery path if my app has to be restarted.
So the background thread will do the following:
1.) Add new security tokens to the database.
2.) Remove expired security tokens from the cache.
So the cache needs to support read write access on background threads. It was my understanding that access to Cache was threadsafe, however does this remain so if I am using the cache from a background thread?
I understand that as I am accessing the Cache from a background thread I need to call:
System.Web.HttpRuntime
.Cache as there is no current Request.
Accessing the ASP.NET Cache from a Separate Thread?
This question details something similar.
Thanks for looking, any answers gratefully received.