开发者

Google app engine - what is the lifecycle of PersistenceManager?

开发者 https://www.devze.com 2022-12-18 10:54 出处:网络
What is the preferred way of using GAE datastore PersistenceManager for web app? GAE instructions are a bit ambiguous on the matter.

What is the preferred way of using GAE datastore PersistenceManager for web app? GAE instructions are a bit ambiguous on the matter.

Do I instantiate PersistenceManagerFactory for each RPC call, or do I use only one factory for all requests? Do I call PMF.get().getPersistenceManager(), or do I call PMF.get().getPersistenceManagerProxy()? Do I close PM after each RPC call, or do 开发者_JS百科I leave it open? What are you guys doing?

Furthermore, I'm not certain how GAE handles 30-second-per-request limit. Is it even possible to reference the same PM between requests?


A PMF is expensive to create, hence only one per app makes sense. And getting a PM per request also makes sense since not expensive. Really depends what you're planning on doing with the objects between requests, whether you want to detach them, and then reattach on a subsequent request.

GAE/J app recycling obviously causes a new PMF hence a delay, something that is for Google to address; there's a thread on their forum that looked at timings of initialisation of various things and I suggested what they could do but its for them to put resource into that effort.

HTH

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号