Is getServletContext() officially supported in GAE?
Is getServlet开发者_如何学运维Context()
officially supported in GAE?
- is it ok if servers are distributed among diff locations?
- performance?
- could I use 'synchronize' within the doPost or in a task queue before updating a value in the context?
It's part of the basic servlet spec, so yes, it's supported. However, as the docs say:
In the case of a web application marked "distributed" in its deployment descriptor, there will be one context instance for each virtual machine. In this situation, the context cannot be used as a location to share global information (because the information won't be truly global). Use an external resource like a database instead.
You can use the ServletContext but there will be one context per instance of your app. So you can't rely on the ServletContext to share information globally. You do have alternatives though (and good ones at that) - use either memcache or the datastore.
精彩评论