I have some objects and classes that I’m currently saving into HttpContext.Cache but I want to make these persistent even when the app pool is recycled or even when the machine has been restarted.
I tried looking into using AppFabric or Memcached but they seemed focused on distributed cache and not so much local cache.
Also the EF STE in combination with AppFabric seem to be depending on serializable classes and some properties in my classes is for example references to .NET classes that is not serializable (For example I have a reference to an instance of System.Net.WebSockets.WebSocket as a property).
So my question is:
Can anyone give me any good ideas or point me to a framework that will allow me to save classes into some sort of local cache that is persistent to disk (Or database if it will allow me to save anyhting into it)?
The new Appfabric 1.1 has read-through and write-behind features which has guaranteed persistence of your cache.
Read through – If a requested item doesn’t exist in the cache, the data can be loaded from backend store and then inserted into cache. With a read-through provider, the cache detects the missing item and calls the provider to perform the data load. The item is then seamlessly returned to the cache client.
Write behind – In the same way, items that are added or updated in the cache can be periodically written to the backend store using a write-through provider. This happens asynchronously and on an interval defined by the cache.
You can check out my blog post for implementation details here http://blogs.msdn.com/b/prathul/archive/2011/12/06/appfabric-cache-read-from-amp-write-to-database-read-through-write-behind.aspx