applicationstate in mvc
I'm using Application[""] to store a few lists of very small size. I would ideally set it at only place.. Application_Start
... but is there a chance the data might get lost in middle and I might have to store these lists back in Application inside places other than App开发者_如何学Clication_Start? If yes, should I be prepared for any kind of race condition?
Let me know if any other concerns you have about using application_Data (like scalability??)... but the size itself of the data I will be storing in it will stay very small.
I'm no expert, but if the lists are being generated at runtime and then stored as Application variables, they will be lost when the app pool recycles. I'm not sure but I think that this can be resolved based. See this question for more details.
Race conditions do occur but they afaik that is managed by the Application. You could always use the Application.Lock()
function if need be as described here.
Have a look at this MSDN article regarding Application State which is good read and addresses your concerns. In short, the following are regarded as issues to be aware of:
- Memory impact of storing something
- Concurrency and synchronisation
- Scalability implications of storing application variables
- Life-cycle implications of information stored in application state - not durable
精彩评论