views:

40

answers:

2

I have a MVC2 web app without a database that is being hosted by IIS7. The model is a custom index of some properties of a filesystem, and right now the index is stored in memory. The problem is that on a regular basis, the data stored in memory gets released, and the index must be recreated. Maybe the best solution would be to serialize the index object and load it when the index gets released, but it would be much simpler if I could prevent the data from going anywhere.

+1  A: 

Anytime there is no activity for a certain amount of time or IIS recycles the process you are going to lose any data in memory so if you require that information, you are going to need to persist it in some way and retrieve it when the memory is cleared.

Have you considered having this data in a persistent xml file or serialized to a file on the server?

If it gets cleared from memory you could check for that case and then just reload the file back into the application cache.

Kelsey
A: 

To allow the data to survive you are going to have to move it outside the pervue of IIS - and that means either an XML store (in App_Data, Isolated Storage or somewhere else), a Database, or a service.

I mention a service because, while its potentially overkill, I imagine that there is some caretaking that needs to be done with this data as well? Removing stale entries, adding new entries and generally taking care of housekeeping? Putting all of that into a service allows the data to persist outside of the limits of IIS (but beware how far this is taken, as at some point you may just be reinventing some aspects of a database server anyway).

Moo