How can Azure maintain APPLICATION state?

早过忘川 提交于 2019-12-07 11:14:43

问题


I know how Azure preserves SESSION state -- I've implemented it in my app using AppFabric based on Neil MacKenzie's Microsoft Windows Azure Development Cookbook. However, that approach based on AppFabric apparently does not preserve APPLICATION state (e.g. Application["name"] = MyObject ), which my app needs.

I suspect I will need to use Azure Tables, but that will require recoding. So before going down that path, I'd like to know if there is a simpler approach to preserve application state, preferably one that does not require recoding of my app.

Thanks,

Bill


回答1:


Sorry, there's nothing like a direct replacement for the Application[key] approach.

Your best bet would be to use Azure caching. You're already using Azure caching indirectly I believe, using the approach from the book above for Session state.

The downside perhaps is that cached items don't stay around forever, their max life is about 72 hours. So anytime you access a cached item, you'll have to test similar to the psuedo code below:

object o = cache.Get("MyItem"); 
if (o != null){ 
   MyType myType = (MyType) o; 
   //use the item
} 
else 
{  
//recreate the item 
}



回答2:


It's worth noting, that Microsoft recommends SQL database as the preferred storage way for server-side state management.

Although I would stick to Azure caching as mentioned by Chris.



来源:https://stackoverflow.com/questions/10761209/how-can-azure-maintain-application-state

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!