How can Azure maintain APPLICATION state?
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 (eg 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
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
}
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.
链接地址: http://www.djcxy.com/p/61524.html